@@ -352,29 +352,29 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
352352 * end while
353353 * ```
354354 *
355- * @param methodSymbol the symbol of the new method
355+ * @param memberDef the transformed lazy field member definition
356356 * @param claz the class containing this lazy val field
357357 * @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
360358 * @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+
366363 */
367- def mkThreadSafeDef (methodSymbol : TermSymbol ,
364+ def mkThreadSafeDef (memberDef : ValOrDefDef ,
368365 claz : ClassSymbol ,
369366 target : Symbol ,
370- rhs : Tree ,
371- tp : Type ,
372367 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
378378 val discardSymb = newSymbol(methodSymbol, lazyNme.discard, Method | Synthetic , MethodType (Nil )(_ => Nil , _ => defn.UnitType ))
379379 val discardDef = DefDef (discardSymb, initBlock(
380380 objCasFlag.appliedTo(thiz, offset, evaluating, Select (New (waiting), StdNames .nme.CONSTRUCTOR ).ensureApplied)
@@ -447,7 +447,6 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
447447 assert(! (x.symbol is Mutable ))
448448
449449 val runtimeModule = " scala.runtime.LazyVals"
450- val tpe = x.tpe.widen.resultType.widen
451450 val claz = x.symbol.owner.asClass
452451 val thizClass = Literal (Constant (claz.info))
453452 val helperModule = requiredModule(runtimeModule)
@@ -482,11 +481,6 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
482481 val fieldTree = thizClass.select(lazyNme.RLazyVals .getDeclaredField).appliedTo(Literal (Constant (containerName.mangledString)))
483482 val offsetTree = ValDef (offsetSymbol.nn, getOffset.appliedTo(fieldTree))
484483 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)
490484
491485 val offset = ref(offsetSymbol.nn)
492486
@@ -496,9 +490,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
496490 else
497491 This (claz)
498492
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)
502494 Thicket (containerTree, accessor)
503495 }
504496}
0 commit comments