Skip to content

Commit c1c2c8e

Browse files
authored
Align nomenclature of Scala2 library compilation (#18711)
Follow up name changes in #18615 and align with flag added in #18613.
2 parents d652c3e + b58f691 commit c1c2c8e

File tree

10 files changed

+20
-20
lines changed

10 files changed

+20
-20
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ object desugar {
505505
def isNonEnumCase = !isEnumCase && (isCaseClass || isCaseObject)
506506
val isValueClass = parents.nonEmpty && isAnyVal(parents.head)
507507
// This is not watertight, but `extends AnyVal` will be replaced by `inline` later.
508-
val caseClassInScala2StdLib = isCaseClass && ctx.settings.Yscala2Stdlib.value
508+
val caseClassInScala2Library = isCaseClass && ctx.settings.YcompileScala2Library.value
509509

510510
val originalTparams = constr1.leadingTypeParams
511511
val originalVparamss = asTermOnly(constr1.trailingParamss)
@@ -684,7 +684,7 @@ object desugar {
684684
DefDef(name, Nil, tpt, rhs).withMods(synthetic)
685685

686686
def productElemMeths =
687-
if caseClassInScala2StdLib then Nil
687+
if caseClassInScala2Library then Nil
688688
else
689689
val caseParams = derivedVparamss.head.toArray
690690
val selectorNamesInBody = normalizedBody.collect {
@@ -715,7 +715,7 @@ object desugar {
715715
val copyRestParamss = derivedVparamss.tail.nestedMap(vparam =>
716716
cpy.ValDef(vparam)(rhs = EmptyTree))
717717
var flags = Synthetic | constr1.mods.flags & copiedAccessFlags
718-
if ctx.settings.Yscala2Stdlib.value then flags &~= Private
718+
if ctx.settings.YcompileScala2Library.value then flags &~= Private
719719
DefDef(
720720
nme.copy,
721721
joinParams(derivedTparams, copyFirstParams :: copyRestParamss),
@@ -776,7 +776,7 @@ object desugar {
776776
else {
777777
val appMods =
778778
var flags = Synthetic | constr1.mods.flags & copiedAccessFlags
779-
if ctx.settings.Yscala2Stdlib.value then flags &~= Private
779+
if ctx.settings.YcompileScala2Library.value then flags &~= Private
780780
Modifiers(flags).withPrivateWithin(constr1.mods.privateWithin)
781781
val appParamss =
782782
derivedVparamss.nestedZipWithConserve(constrVparamss)((ap, cp) =>
@@ -802,7 +802,7 @@ object desugar {
802802
val unapplyParam = makeSyntheticParameter(tpt = classTypeRef)
803803
val unapplyRHS =
804804
if (arity == 0) Literal(Constant(true))
805-
else if caseClassInScala2StdLib then scala2LibCompatUnapplyRhs(unapplyParam.name)
805+
else if caseClassInScala2Library then scala2LibCompatUnapplyRhs(unapplyParam.name)
806806
else Ident(unapplyParam.name)
807807
val unapplyResTp = if (arity == 0) Literal(Constant(true)) else TypeTree()
808808

@@ -860,7 +860,7 @@ object desugar {
860860
// TODO: drop this once we do not silently insert empty class parameters anymore
861861
case paramss => paramss
862862
}
863-
val finalFlag = if ctx.settings.Yscala2Stdlib.value then EmptyFlags else Final
863+
val finalFlag = if ctx.settings.YcompileScala2Library.value then EmptyFlags else Final
864864
// implicit wrapper is typechecked in same scope as constructor, so
865865
// we can reuse the constructor parameters; no derived params are needed.
866866
DefDef(

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ private sealed trait YSettings:
395395
val YfromTastyIgnoreList: Setting[List[String]] = MultiStringSetting("-Yfrom-tasty-ignore-list", "file", "List of `tasty` files in jar files that will not be loaded when using -from-tasty.")
396396
val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features.")
397397
val YlegacyLazyVals: Setting[Boolean] = BooleanSetting("-Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.")
398-
val Yscala2Stdlib: Setting[Boolean] = BooleanSetting("-Yscala2-stdlib", "Used when compiling the Scala 2 standard library.")
398+
val YcompileScala2Library: Setting[Boolean] = BooleanSetting("-Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.")
399399
val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting("-Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles")
400400

401401
val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.")

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ class Definitions {
14211421
denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted
14221422
patch2(denot, patchCls)
14231423

1424-
if ctx.settings.Yscala2Stdlib.value then
1424+
if ctx.settings.YcompileScala2Library.value then
14251425
()
14261426
else if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then
14271427
patchWith(ScalaPredefModuleClassPatch)
@@ -1769,7 +1769,7 @@ class Definitions {
17691769
|| tp.derivesFrom(defn.PolyFunctionClass) // TODO check for refinement?
17701770

17711771
private def withSpecMethods(cls: ClassSymbol, bases: List[Name], paramTypes: Set[TypeRef]) =
1772-
if !ctx.settings.Yscala2Stdlib.value then
1772+
if !ctx.settings.YcompileScala2Library.value then
17731773
for base <- bases; tp <- paramTypes do
17741774
cls.enter(newSymbol(cls, base.specializedName(List(tp)), Method, ExprType(tp)))
17751775
cls
@@ -1812,7 +1812,7 @@ class Definitions {
18121812
case List(x, y) => Tuple2SpecializedParamClasses().contains(x.classSymbol) && Tuple2SpecializedParamClasses().contains(y.classSymbol)
18131813
case _ => false
18141814
&& base.owner.denot.info.member(base.name.specializedName(args)).exists // when dotc compiles the stdlib there are no specialised classes
1815-
&& !ctx.settings.Yscala2Stdlib.value // We do not add the specilized TupleN methods/classes when compiling the stdlib
1815+
&& !ctx.settings.YcompileScala2Library.value // We do not add the specilized TupleN methods/classes when compiling the stdlib
18161816

18171817
def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(using Context): Boolean =
18181818
paramTypes.length <= 2
@@ -1834,7 +1834,7 @@ class Definitions {
18341834
case _ =>
18351835
false
18361836
})
1837-
&& !ctx.settings.Yscala2Stdlib.value // We do not add the specilized FunctionN methods/classes when compiling the stdlib
1837+
&& !ctx.settings.YcompileScala2Library.value // We do not add the specilized FunctionN methods/classes when compiling the stdlib
18381838

18391839
@tu lazy val Function0SpecializedApplyNames: List[TermName] =
18401840
for r <- Function0SpecializedReturnTypes

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
241241
}
242242

243243
private def checkScala2Stdlib(using Context): Unit =
244-
assert(!ctx.settings.Yscala2Stdlib.value, "No Scala 2 libraries should be unpickled under -Yscala2-stdlib")
244+
assert(!ctx.settings.YcompileScala2Library.value, "No Scala 2 libraries should be unpickled under -Ycompile-scala2-library")
245245

246246
/** The `decls` scope associated with given symbol */
247247
protected def symScope(sym: Symbol): Scope = symScopes.getOrElseUpdate(sym, newScope(0))

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
8282

8383
private var compilingScala2StdLib = false
8484
override def initContext(ctx: FreshContext): Unit =
85-
compilingScala2StdLib = ctx.settings.Yscala2Stdlib.value(using ctx)
85+
compilingScala2StdLib = ctx.settings.YcompileScala2Library.value(using ctx)
8686

8787
val superAcc: SuperAccessors = new SuperAccessors(thisPhase)
8888
val synthMbr: SyntheticMembers = new SyntheticMembers(thisPhase)

compiler/src/dotty/tools/dotc/transform/SpecializeApplyMethods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
2525
override def description: String = SpecializeApplyMethods.description
2626

2727
override def isEnabled(using Context): Boolean =
28-
!ctx.settings.scalajs.value && !ctx.settings.Yscala2Stdlib.value
28+
!ctx.settings.scalajs.value && !ctx.settings.YcompileScala2Library.value
2929

3030
private def specApplySymbol(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = {
3131
val name = nme.apply.specializedFunction(ret, args)

compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
162162
case nme.productPrefix if isEnumValue => nameRef
163163
case nme.productPrefix => ownName
164164
case nme.productElement =>
165-
if ctx.settings.Yscala2Stdlib.value then productElementBodyForScala2Compat(accessors.length, vrefss.head.head)
165+
if ctx.settings.YcompileScala2Library.value then productElementBodyForScala2Compat(accessors.length, vrefss.head.head)
166166
else productElementBody(accessors.length, vrefss.head.head)
167167
case nme.productElementName => productElementNameBody(accessors.length, vrefss.head.head)
168168
}
@@ -666,7 +666,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
666666
val syntheticMembers = serializableObjectMethod(clazz) ::: serializableEnumValueMethod(clazz) ::: caseAndValueMethods(clazz)
667667
checkInlining(syntheticMembers)
668668
val impl1 = cpy.Template(impl)(body = syntheticMembers ::: impl.body)
669-
if ctx.settings.Yscala2Stdlib.value then impl1
669+
if ctx.settings.YcompileScala2Library.value then impl1
670670
else addMirrorSupport(impl1)
671671
}
672672

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
27492749

27502750
checkEnumParent(cls, firstParent)
27512751

2752-
if defn.ScalaValueClasses()(cls) && ctx.settings.Yscala2Stdlib.value then
2752+
if defn.ScalaValueClasses()(cls) && ctx.settings.YcompileScala2Library.value then
27532753
constr1.symbol.resetFlag(Private)
27542754

27552755
val self1 = typed(self)(using ctx.outer).asInstanceOf[ValDef] // outer context where class members are not visible
@@ -2789,7 +2789,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
27892789
&& !cls.isAllOf(PrivateLocal)
27902790
&& effectiveOwner.is(Trait)
27912791
&& !effectiveOwner.derivesFrom(defn.ObjectClass)
2792-
&& !ctx.settings.Yscala2Stdlib.value // FIXME?: class PermutationsItr cannot be defined in universal trait SeqOps
2792+
&& !ctx.settings.YcompileScala2Library.value // FIXME?: class PermutationsItr cannot be defined in universal trait SeqOps
27932793
then
27942794
report.error(em"$cls cannot be defined in universal $effectiveOwner", cdef.srcPos)
27952795

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ object Build {
10081008
Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString)
10091009
},
10101010
Compile / doc / scalacOptions += "-Ydocument-synthetic-types",
1011-
scalacOptions += "-Yscala2-stdlib",
1011+
scalacOptions += "-Ycompile-scala2-library",
10121012
scalacOptions += "-Ycheck:all",
10131013
scalacOptions -= "-Xfatal-warnings",
10141014
ivyConfigurations += SourceDeps.hide,

project/TastyMiMaFilters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object TastyMiMaFilters {
2424
// In Scala 3 these accessors are added in the `postyper` phase.
2525
// In Scala 2 these accessors are added in the `superaccessors` phase after typer.
2626
// Are these accessors in the Scala 2 pickles? If so, it implies that TASTy Query/MiMa is ignoring them in Scala 2 but not Scala 3.
27-
// Otherwise, if these are not in the Scala 2 pickles, we might need to remove them when compiling with -Yscala2-stdlib
27+
// Otherwise, if these are not in the Scala 2 pickles, we might need to remove them when compiling with -Ycompile-scala2-library
2828
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.IndexedSeqOps.superscala$collection$immutable$IndexedSeqOps$$slice"),
2929
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.StrictOptimizedSeqOps.superscala$collection$immutable$StrictOptimizedSeqOps$$sorted"),
3030
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.IndexedSeq.superscala$collection$immutable$IndexedSeq$$*"/* sameElements, canEqual */),

0 commit comments

Comments
 (0)