@@ -19,6 +19,7 @@ import printing.Formatting.hl
19
19
import config .Printers
20
20
21
21
import scala .annotation .internal .sharable
22
+ import scala .annotation .threadUnsafe
22
23
23
24
object desugar {
24
25
import untpd ._
@@ -440,6 +441,8 @@ object desugar {
440
441
441
442
/** The expansion of a class definition. See inline comments for what is involved */
442
443
def classDef (cdef : TypeDef )(using Context ): Tree = {
444
+ @ threadUnsafe lazy val compilingScala2StdLib = ctx.settings.Yscala2Stdlib .value
445
+
443
446
val impl @ Template (constr0, _, self, _) = cdef.rhs: @ unchecked
444
447
val className = normalizeName(cdef, impl).asTypeName
445
448
val parents = impl.parents
@@ -662,9 +665,7 @@ object desugar {
662
665
// new C[...](p1, ..., pN)(moreParams)
663
666
val (caseClassMeths, enumScaffolding) = {
664
667
def syntheticProperty (name : TermName , tpt : Tree , rhs : Tree ) =
665
- val mods =
666
- if ctx.settings.Yscala2Stdlib .value then synthetic | Inline
667
- else synthetic
668
+ val mods = if compilingScala2StdLib then synthetic | Inline else synthetic
668
669
DefDef (name, Nil , tpt, rhs).withMods(mods)
669
670
670
671
def productElemMeths =
@@ -778,7 +779,7 @@ object desugar {
778
779
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
779
780
val unapplyRHS =
780
781
if (arity == 0 ) Literal (Constant (true ))
781
- else if ctx.settings. Yscala2Stdlib .value then scala2LibCompatUnapplyRhs(unapplyParam.name)
782
+ else if compilingScala2StdLib then scala2LibCompatUnapplyRhs(unapplyParam.name)
782
783
else Ident (unapplyParam.name)
783
784
val unapplyResTp = if (arity == 0 ) Literal (Constant (true )) else TypeTree ()
784
785
0 commit comments