From b58f691f9da58dda5428b7572cfb6c99c092c81a Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 17 Oct 2023 17:05:34 +0200 Subject: [PATCH] Align nomenclature of Scala2 library compilation Follow up name changes in #18615 and align with flag added in #18613. --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 12 ++++++------ .../src/dotty/tools/dotc/config/ScalaSettings.scala | 2 +- compiler/src/dotty/tools/dotc/core/Definitions.scala | 8 ++++---- .../dotc/core/unpickleScala2/Scala2Unpickler.scala | 2 +- .../src/dotty/tools/dotc/transform/PostTyper.scala | 2 +- .../dotc/transform/SpecializeApplyMethods.scala | 2 +- .../tools/dotc/transform/SyntheticMembers.scala | 4 ++-- compiler/src/dotty/tools/dotc/typer/Typer.scala | 4 ++-- project/Build.scala | 2 +- project/TastyMiMaFilters.scala | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 6024eab29722..7f71e4b3c467 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -505,7 +505,7 @@ object desugar { def isNonEnumCase = !isEnumCase && (isCaseClass || isCaseObject) val isValueClass = parents.nonEmpty && isAnyVal(parents.head) // This is not watertight, but `extends AnyVal` will be replaced by `inline` later. - val caseClassInScala2StdLib = isCaseClass && ctx.settings.Yscala2Stdlib.value + val caseClassInScala2Library = isCaseClass && ctx.settings.YcompileScala2Library.value val originalTparams = constr1.leadingTypeParams val originalVparamss = asTermOnly(constr1.trailingParamss) @@ -684,7 +684,7 @@ object desugar { DefDef(name, Nil, tpt, rhs).withMods(synthetic) def productElemMeths = - if caseClassInScala2StdLib then Nil + if caseClassInScala2Library then Nil else val caseParams = derivedVparamss.head.toArray val selectorNamesInBody = normalizedBody.collect { @@ -715,7 +715,7 @@ object desugar { val copyRestParamss = derivedVparamss.tail.nestedMap(vparam => cpy.ValDef(vparam)(rhs = EmptyTree)) var flags = Synthetic | constr1.mods.flags & copiedAccessFlags - if ctx.settings.Yscala2Stdlib.value then flags &~= Private + if ctx.settings.YcompileScala2Library.value then flags &~= Private DefDef( nme.copy, joinParams(derivedTparams, copyFirstParams :: copyRestParamss), @@ -776,7 +776,7 @@ object desugar { else { val appMods = var flags = Synthetic | constr1.mods.flags & copiedAccessFlags - if ctx.settings.Yscala2Stdlib.value then flags &~= Private + if ctx.settings.YcompileScala2Library.value then flags &~= Private Modifiers(flags).withPrivateWithin(constr1.mods.privateWithin) val appParamss = derivedVparamss.nestedZipWithConserve(constrVparamss)((ap, cp) => @@ -802,7 +802,7 @@ object desugar { val unapplyParam = makeSyntheticParameter(tpt = classTypeRef) val unapplyRHS = if (arity == 0) Literal(Constant(true)) - else if caseClassInScala2StdLib then scala2LibCompatUnapplyRhs(unapplyParam.name) + else if caseClassInScala2Library then scala2LibCompatUnapplyRhs(unapplyParam.name) else Ident(unapplyParam.name) val unapplyResTp = if (arity == 0) Literal(Constant(true)) else TypeTree() @@ -860,7 +860,7 @@ object desugar { // TODO: drop this once we do not silently insert empty class parameters anymore case paramss => paramss } - val finalFlag = if ctx.settings.Yscala2Stdlib.value then EmptyFlags else Final + val finalFlag = if ctx.settings.YcompileScala2Library.value then EmptyFlags else Final // implicit wrapper is typechecked in same scope as constructor, so // we can reuse the constructor parameters; no derived params are needed. DefDef( diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 925be029746e..e2c3eef6f467 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -395,7 +395,7 @@ private sealed trait YSettings: 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.") val YnoExperimental: Setting[Boolean] = BooleanSetting("-Yno-experimental", "Disable experimental language features.") val YlegacyLazyVals: Setting[Boolean] = BooleanSetting("-Ylegacy-lazy-vals", "Use legacy (pre 3.3.0) implementation of lazy vals.") - val Yscala2Stdlib: Setting[Boolean] = BooleanSetting("-Yscala2-stdlib", "Used when compiling the Scala 2 standard library.") + val YcompileScala2Library: Setting[Boolean] = BooleanSetting("-Ycompile-scala2-library", "Used when compiling the Scala 2 standard library.") val YoutputOnlyTasty: Setting[Boolean] = BooleanSetting("-Youtput-only-tasty", "Used to only generate the TASTy file without the classfiles") val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.") diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index ebe5463d8cdf..b0b9efb4a512 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1421,7 +1421,7 @@ class Definitions { denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted patch2(denot, patchCls) - if ctx.settings.Yscala2Stdlib.value then + if ctx.settings.YcompileScala2Library.value then () else if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then patchWith(ScalaPredefModuleClassPatch) @@ -1769,7 +1769,7 @@ class Definitions { || tp.derivesFrom(defn.PolyFunctionClass) // TODO check for refinement? private def withSpecMethods(cls: ClassSymbol, bases: List[Name], paramTypes: Set[TypeRef]) = - if !ctx.settings.Yscala2Stdlib.value then + if !ctx.settings.YcompileScala2Library.value then for base <- bases; tp <- paramTypes do cls.enter(newSymbol(cls, base.specializedName(List(tp)), Method, ExprType(tp))) cls @@ -1812,7 +1812,7 @@ class Definitions { case List(x, y) => Tuple2SpecializedParamClasses().contains(x.classSymbol) && Tuple2SpecializedParamClasses().contains(y.classSymbol) case _ => false && base.owner.denot.info.member(base.name.specializedName(args)).exists // when dotc compiles the stdlib there are no specialised classes - && !ctx.settings.Yscala2Stdlib.value // We do not add the specilized TupleN methods/classes when compiling the stdlib + && !ctx.settings.YcompileScala2Library.value // We do not add the specilized TupleN methods/classes when compiling the stdlib def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(using Context): Boolean = paramTypes.length <= 2 @@ -1834,7 +1834,7 @@ class Definitions { case _ => false }) - && !ctx.settings.Yscala2Stdlib.value // We do not add the specilized FunctionN methods/classes when compiling the stdlib + && !ctx.settings.YcompileScala2Library.value // We do not add the specilized FunctionN methods/classes when compiling the stdlib @tu lazy val Function0SpecializedApplyNames: List[TermName] = for r <- Function0SpecializedReturnTypes diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index 481768fb4dbf..a2bba7e708b2 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -241,7 +241,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas } private def checkScala2Stdlib(using Context): Unit = - assert(!ctx.settings.Yscala2Stdlib.value, "No Scala 2 libraries should be unpickled under -Yscala2-stdlib") + assert(!ctx.settings.YcompileScala2Library.value, "No Scala 2 libraries should be unpickled under -Ycompile-scala2-library") /** The `decls` scope associated with given symbol */ protected def symScope(sym: Symbol): Scope = symScopes.getOrElseUpdate(sym, newScope(0)) diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 4f3f92eddb2f..ff322dad9ab6 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -82,7 +82,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase => private var compilingScala2StdLib = false override def initContext(ctx: FreshContext): Unit = - compilingScala2StdLib = ctx.settings.Yscala2Stdlib.value(using ctx) + compilingScala2StdLib = ctx.settings.YcompileScala2Library.value(using ctx) val superAcc: SuperAccessors = new SuperAccessors(thisPhase) val synthMbr: SyntheticMembers = new SyntheticMembers(thisPhase) diff --git a/compiler/src/dotty/tools/dotc/transform/SpecializeApplyMethods.scala b/compiler/src/dotty/tools/dotc/transform/SpecializeApplyMethods.scala index 5cde660d2884..5c5c02c1bc75 100644 --- a/compiler/src/dotty/tools/dotc/transform/SpecializeApplyMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/SpecializeApplyMethods.scala @@ -25,7 +25,7 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer { override def description: String = SpecializeApplyMethods.description override def isEnabled(using Context): Boolean = - !ctx.settings.scalajs.value && !ctx.settings.Yscala2Stdlib.value + !ctx.settings.scalajs.value && !ctx.settings.YcompileScala2Library.value private def specApplySymbol(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = { val name = nme.apply.specializedFunction(ret, args) diff --git a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala index 826787e153f4..200e7eb2c215 100644 --- a/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala +++ b/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala @@ -162,7 +162,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) { case nme.productPrefix if isEnumValue => nameRef case nme.productPrefix => ownName case nme.productElement => - if ctx.settings.Yscala2Stdlib.value then productElementBodyForScala2Compat(accessors.length, vrefss.head.head) + if ctx.settings.YcompileScala2Library.value then productElementBodyForScala2Compat(accessors.length, vrefss.head.head) else productElementBody(accessors.length, vrefss.head.head) case nme.productElementName => productElementNameBody(accessors.length, vrefss.head.head) } @@ -666,7 +666,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) { val syntheticMembers = serializableObjectMethod(clazz) ::: serializableEnumValueMethod(clazz) ::: caseAndValueMethods(clazz) checkInlining(syntheticMembers) val impl1 = cpy.Template(impl)(body = syntheticMembers ::: impl.body) - if ctx.settings.Yscala2Stdlib.value then impl1 + if ctx.settings.YcompileScala2Library.value then impl1 else addMirrorSupport(impl1) } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 54f75d37b2bf..73167bb51f52 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -2749,7 +2749,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer checkEnumParent(cls, firstParent) - if defn.ScalaValueClasses()(cls) && ctx.settings.Yscala2Stdlib.value then + if defn.ScalaValueClasses()(cls) && ctx.settings.YcompileScala2Library.value then constr1.symbol.resetFlag(Private) 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 && !cls.isAllOf(PrivateLocal) && effectiveOwner.is(Trait) && !effectiveOwner.derivesFrom(defn.ObjectClass) - && !ctx.settings.Yscala2Stdlib.value // FIXME?: class PermutationsItr cannot be defined in universal trait SeqOps + && !ctx.settings.YcompileScala2Library.value // FIXME?: class PermutationsItr cannot be defined in universal trait SeqOps then report.error(em"$cls cannot be defined in universal $effectiveOwner", cdef.srcPos) diff --git a/project/Build.scala b/project/Build.scala index d3c57653beb6..48658e005d95 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -993,7 +993,7 @@ object Build { Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString) }, Compile / doc / scalacOptions += "-Ydocument-synthetic-types", - scalacOptions += "-Yscala2-stdlib", + scalacOptions += "-Ycompile-scala2-library", scalacOptions += "-Ycheck:all", scalacOptions -= "-Xfatal-warnings", ivyConfigurations += SourceDeps.hide, diff --git a/project/TastyMiMaFilters.scala b/project/TastyMiMaFilters.scala index 5aceb44a3837..1573e54dd4eb 100644 --- a/project/TastyMiMaFilters.scala +++ b/project/TastyMiMaFilters.scala @@ -24,7 +24,7 @@ object TastyMiMaFilters { // In Scala 3 these accessors are added in the `postyper` phase. // In Scala 2 these accessors are added in the `superaccessors` phase after typer. // 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. - // Otherwise, if these are not in the Scala 2 pickles, we might need to remove them when compiling with -Yscala2-stdlib + // Otherwise, if these are not in the Scala 2 pickles, we might need to remove them when compiling with -Ycompile-scala2-library ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.IndexedSeqOps.superscala$collection$immutable$IndexedSeqOps$$slice"), ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.StrictOptimizedSeqOps.superscala$collection$immutable$StrictOptimizedSeqOps$$sorted"), ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.collection.immutable.IndexedSeq.superscala$collection$immutable$IndexedSeq$$*"/* sameElements, canEqual */),