@@ -352,29 +352,29 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
352
352
* end while
353
353
* ```
354
354
*
355
- * @param methodSymbol the symbol of the new method
355
+ * @param memberDef the transformed lazy field member definition
356
356
* @param claz the class containing this lazy val field
357
357
* @param target the target synthetic field
358
- * @param rhs the right-hand side expression of the lazy val
359
- * @param tp the type of the lazy val
360
358
* @param offset the offset of the field in the bitmap
361
- * @param getFlag a flag for the volatile get function
362
- * @param objCasFlag a flag for the CAS function operating on objects
363
- * @param waiting a reference to the `Waiting` runtime class
364
- * @param evaluating a reference to the `Evaluating` runtime object
365
- * @param nullValued a reference to the `NULL` runtime object
359
+ * @param thiz a reference to the `NULL` runtime object
360
+ * @param helperModule the symbol of the runtime LazyVals helper module
361
+ * @param runtimeModule the runtime LazyVals module path
362
+
366
363
*/
367
- def mkThreadSafeDef (methodSymbol : TermSymbol ,
364
+ def mkThreadSafeDef (memberDef : ValOrDefDef ,
368
365
claz : ClassSymbol ,
369
366
target : Symbol ,
370
- rhs : Tree ,
371
- tp : Type ,
372
367
offset : Tree ,
373
- objCasFlag : Tree ,
374
- waiting : Tree ,
375
- evaluating : Tree ,
376
- nullValued : Tree ,
377
- thiz : Tree )(using Context ): DefDef = {
368
+ thiz : Tree ,
369
+ helperModule : TermSymbol ,
370
+ runtimeModule : String )(using Context ): DefDef = {
371
+ val tp = memberDef.tpe.widen.resultType.widen
372
+ val waiting = ref(requiredClass(s " $runtimeModule. ${lazyNme.RLazyVals .waiting}" ))
373
+ val evaluating = Select (ref(helperModule), lazyNme.RLazyVals .evaluating)
374
+ val nullValued = Select (ref(helperModule), lazyNme.RLazyVals .nullValued)
375
+ val objCasFlag = Select (ref(helperModule), lazyNme.RLazyVals .objCas)
376
+ val methodSymbol = memberDef.symbol.asTerm
377
+ val rhs = memberDef.rhs
378
378
val discardSymb = newSymbol(methodSymbol, lazyNme.discard, Method | Synthetic , MethodType (Nil )(_ => Nil , _ => defn.UnitType ))
379
379
val discardDef = DefDef (discardSymb, initBlock(
380
380
objCasFlag.appliedTo(thiz, offset, evaluating, Select (New (waiting), StdNames .nme.CONSTRUCTOR ).ensureApplied)
@@ -447,7 +447,6 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
447
447
assert(! (x.symbol is Mutable ))
448
448
449
449
val runtimeModule = " scala.runtime.LazyVals"
450
- val tpe = x.tpe.widen.resultType.widen
451
450
val claz = x.symbol.owner.asClass
452
451
val thizClass = Literal (Constant (claz.info))
453
452
val helperModule = requiredModule(runtimeModule)
@@ -482,11 +481,6 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
482
481
val fieldTree = thizClass.select(lazyNme.RLazyVals .getDeclaredField).appliedTo(Literal (Constant (containerName.mangledString)))
483
482
val offsetTree = ValDef (offsetSymbol.nn, getOffset.appliedTo(fieldTree))
484
483
appendOffsetDefs += (claz -> new OffsetInfo (List (offsetTree)))
485
-
486
- val waiting = requiredClass(s " $runtimeModule. ${lazyNme.RLazyVals .waiting}" )
487
- val evaluating = Select (ref(helperModule), lazyNme.RLazyVals .evaluating)
488
- val nullValued = Select (ref(helperModule), lazyNme.RLazyVals .nullValued)
489
- val objCas = Select (ref(helperModule), lazyNme.RLazyVals .objCas)
490
484
491
485
val offset = ref(offsetSymbol.nn)
492
486
@@ -496,9 +490,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
496
490
else
497
491
This (claz)
498
492
499
- val methodSymbol = x.symbol.asTerm
500
- val accessor = mkThreadSafeDef(methodSymbol, claz, containerSymbol, x.rhs, tpe, offset, objCas,
501
- ref(waiting), evaluating, nullValued, swapOver)
493
+ val accessor = mkThreadSafeDef(x, claz, containerSymbol, offset, swapOver, helperModule, runtimeModule)
502
494
Thicket (containerTree, accessor)
503
495
}
504
496
}
0 commit comments