Skip to content

Commit e23e3df

Browse files
committed
drop -Yno-stdlib-patches setting
[Cherry-picked 3b8240a][modified]
1 parent 0bbae64 commit e23e3df

File tree

12 files changed

+8
-144
lines changed

12 files changed

+8
-144
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ private sealed trait YSettings:
404404
val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during")
405405
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
406406
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
407-
val YnoStdlibPatches: Setting[Boolean] = BooleanSetting(ForkSetting, "Yno-stdlib-patches", "Do not patch stdlib files (temporary and only to be used for the stdlib migration)", false)
408407

409408
val Yreporter: Setting[String] = StringSetting(ForkSetting, name = "Yreporter", helpArg = "<class>", descr = "Specify a dotty.tools.dotc.reporting.Reporter", default = "dotty.tools.dotc.reporting.ConsoleReporter")
410409

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

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,116 +1450,6 @@ class Definitions {
14501450
|| sym.owner == CompiletimeOpsStringModuleClass && compiletimePackageStringTypes.contains(sym.name)
14511451
)
14521452

1453-
// ----- Scala-2 library patches --------------------------------------
1454-
1455-
/** The `scala.runtime.stdLibPacthes` package contains objects
1456-
* that contain defnitions that get added as members to standard library
1457-
* objects with the same name.
1458-
*/
1459-
@tu lazy val StdLibPatchesPackage: TermSymbol = requiredPackage("scala.runtime.stdLibPatches")
1460-
@tu private lazy val ScalaPredefModuleClassPatch: Symbol = getModuleIfDefined("scala.runtime.stdLibPatches.Predef").moduleClass
1461-
@tu private lazy val LanguageModuleClassPatch: Symbol = getModuleIfDefined("scala.runtime.stdLibPatches.language").moduleClass
1462-
1463-
/** If `sym` is a patched library class, the source file of its patch class,
1464-
* otherwise `NoSource`
1465-
*/
1466-
def patchSource(sym: Symbol)(using Context): SourceFile =
1467-
if sym == ScalaPredefModuleClass then ScalaPredefModuleClassPatch.source
1468-
else if sym == LanguageModuleClass then LanguageModuleClassPatch.source
1469-
else NoSource
1470-
1471-
/** A finalizer that patches standard library classes.
1472-
* It copies all non-private, non-synthetic definitions from `patchCls`
1473-
* to `denot` while changing their owners to `denot`. Before that it deletes
1474-
* any definitions of `denot` that have the same name as one of the copied
1475-
* definitions.
1476-
*
1477-
* If an object is present in both the original class and the patch class,
1478-
* it is not overwritten. Instead its members are copied recursively.
1479-
*
1480-
* To avpid running into cycles on bootstrap, patching happens only if `patchCls`
1481-
* is read from a classfile.
1482-
*/
1483-
def patchStdLibClass(denot: ClassDenotation)(using Context): Unit =
1484-
// Do not patch the stdlib files if we explicitly disable it
1485-
// This is only to be used during the migration of the stdlib
1486-
if ctx.settings.YnoStdlibPatches.value then
1487-
return
1488-
1489-
def patch2(denot: ClassDenotation, patchCls: Symbol): Unit =
1490-
val scope = denot.info.decls.openForMutations
1491-
1492-
def recurse(patch: Symbol) = patch.is(Module) && scope.lookup(patch.name).exists
1493-
1494-
def makeClassSymbol(patch: Symbol, parents: List[Type], selfInfo: TypeOrSymbol) =
1495-
newClassSymbol(
1496-
owner = denot.symbol,
1497-
name = patch.name.asTypeName,
1498-
flags = patch.flags,
1499-
// need to rebuild a fresh ClassInfo
1500-
infoFn = cls => ClassInfo(
1501-
prefix = denot.symbol.thisType,
1502-
cls = cls,
1503-
declaredParents = parents, // assume parents in patch don't refer to symbols in the patch
1504-
decls = newScope,
1505-
selfInfo =
1506-
if patch.is(Module)
1507-
then TermRef(denot.symbol.thisType, patch.name.sourceModuleName)
1508-
else selfInfo // assume patch self type annotation does not refer to symbols in the patch
1509-
),
1510-
privateWithin = patch.privateWithin,
1511-
coord = denot.symbol.coord,
1512-
compUnitInfo = denot.symbol.compilationUnitInfo
1513-
)
1514-
1515-
def makeNonClassSymbol(patch: Symbol) =
1516-
if patch.is(Inline) then
1517-
// Inline symbols contain trees in annotations, which is coupled
1518-
// with the underlying symbol.
1519-
// Changing owner for inline symbols is a simple workaround.
1520-
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol)
1521-
patch
1522-
else
1523-
// change `info` which might contain reference to the patch
1524-
patch.copy(
1525-
owner = denot.symbol,
1526-
info =
1527-
if patch.is(Module)
1528-
then TypeRef(denot.symbol.thisType, patch.name.moduleClassName)
1529-
else patch.info // assume non-object info does not refer to symbols in the patch
1530-
)
1531-
1532-
if patchCls.exists then
1533-
val patches = patchCls.info.decls.filter(patch =>
1534-
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
1535-
for patch <- patches if !recurse(patch) do
1536-
val e = scope.lookupEntry(patch.name)
1537-
if e != null then scope.unlink(e)
1538-
for patch <- patches do
1539-
patch.ensureCompleted()
1540-
if !recurse(patch) then
1541-
val sym =
1542-
patch.info match
1543-
case ClassInfo(_, _, parents, _, selfInfo) =>
1544-
makeClassSymbol(patch, parents, selfInfo)
1545-
case _ =>
1546-
makeNonClassSymbol(patch)
1547-
end match
1548-
sym.annotations = patch.annotations
1549-
scope.enter(sym)
1550-
if patch.isClass then
1551-
patch2(scope.lookup(patch.name).asClass, patch)
1552-
1553-
def patchWith(patchCls: Symbol) =
1554-
denot.sourceModule.info = denot.typeRef // we run into a cyclic reference when patching if this line is omitted
1555-
patch2(denot, patchCls)
1556-
1557-
if denot.name == tpnme.Predef.moduleClassName && denot.symbol == ScalaPredefModuleClass then
1558-
patchWith(ScalaPredefModuleClassPatch)
1559-
else if denot.name == tpnme.language.moduleClassName && denot.symbol == LanguageModuleClass then
1560-
patchWith(LanguageModuleClassPatch)
1561-
end patchStdLibClass
1562-
15631453
// ----- Symbol sets ---------------------------------------------------
15641454

15651455
@tu lazy val topClasses: Set[Symbol] = Set(AnyClass, MatchableClass, ObjectClass, AnyValClass)

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,12 @@ object Symbols extends SymUtils {
520520
val file = associatedFile
521521
if file != null && !file.isScalaBinary then
522522
mySource = ctx.getSource(file)
523-
else
524-
mySource = defn.patchSource(this)
525-
if !mySource.exists then
526-
val compUnitInfo = compilationUnitInfo
527-
if compUnitInfo != null then
528-
compUnitInfo.tastyInfo.flatMap(_.attributes.sourceFile) match
529-
case Some(path) => mySource = ctx.getSource(path)
530-
case _ =>
523+
else if !mySource.exists then
524+
val compUnitInfo = compilationUnitInfo
525+
if compUnitInfo != null then
526+
compUnitInfo.tastyInfo.flatMap(_.attributes.sourceFile) match
527+
case Some(path) => mySource = ctx.getSource(path)
528+
case _ =>
531529
if !mySource.exists then
532530
mySource = atPhaseNoLater(flattenPhase) {
533531
denot.topLevelClass.unforcedAnnotation(defn.SourceFileAnnot) match

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,6 @@ class TreeUnpickler(reader: TastyReader,
11581158
val stats = rdr.readIndexedStats(localDummy, end)
11591159
tparams ++ vparams ++ stats
11601160
})
1161-
defn.patchStdLibClass(cls)
11621161
NamerOps.addConstructorProxies(cls)
11631162
NamerOps.addContextBoundCompanions(cls)
11641163
setSpan(start,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ object Scala2Unpickler {
128128

129129
denot.info = tempInfo.finalized(normalizedParents)
130130
denot.ensureTypeParamsInCorrectOrder()
131-
defn.patchStdLibClass(denot)
132131
}
133132
}
134133

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,6 @@ object TreeChecker {
710710
super.typedWhileDo(tree)
711711
}
712712

713-
override def typedPackageDef(tree: untpd.PackageDef)(using Context): Tree =
714-
if tree.symbol == defn.StdLibPatchesPackage then
715-
promote(tree) // don't check stdlib patches, since their symbols were highjacked by stdlib classes
716-
else
717-
super.typedPackageDef(tree)
718-
719713
override def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree =
720714
if ctx.phase <= stagingPhase.prev then
721715
assert(tree.tags.isEmpty, i"unexpected tags in Quote before staging phase: ${tree.tags}")

compiler/src/dotty/tools/dotc/transform/init/Util.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ object Util:
117117
}
118118

119119
// A concrete class may not be instantiated if the self type is not satisfied
120-
instantiable && cls.enclosingPackageClass != defn.StdLibPatchesPackage.moduleClass
120+
instantiable
121121

122122
/** Whether the class or its super class/trait contains any mutable fields? */
123123
def isMutable(cls: ClassSymbol)(using Context): Boolean =

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,6 @@ class Namer { typer: Typer =>
17731773
cls.setStableConstructor()
17741774
enterParentRefinementSyms(parentRefinements.toList)
17751775
processExports(using localCtx)
1776-
defn.patchStdLibClass(cls)
17771776
addConstructorProxies(cls)
17781777
cleanup()
17791778
}

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object TestConfiguration {
7373

7474
val commonOptions = Array("-indent") ++ checkOptions ++ noCheckOptions ++ yCheckOptions ++ silenceOptions
7575
val noYcheckCommonOptions = Array("-indent") ++ checkOptions ++ noCheckOptions
76-
val defaultOptions = TestFlags(basicClasspath, commonOptions) `and` "-Yno-stdlib-patches"
76+
val defaultOptions = TestFlags(basicClasspath, commonOptions)
7777
val noYcheckOptions = TestFlags(basicClasspath, noYcheckCommonOptions)
7878
val bestEffortBaselineOptions = TestFlags(basicClasspath, noCheckOptions)
7979
val unindentOptions = TestFlags(basicClasspath, Array("-no-indent") ++ checkOptions ++ noCheckOptions ++ yCheckOptions)

project/Build.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,6 @@ object Build {
20512051
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
20522052
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
20532053
Compile / compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
2054-
Compile / compile / scalacOptions += "-Yno-stdlib-patches",
20552054
Compile / compile / scalacOptions += "-Yexplicit-nulls",
20562055
Compile / compile / scalacOptions ++= Seq(
20572056
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
@@ -2192,7 +2191,6 @@ object Build {
21922191
(`scala-library-bootstrapped` / Compile / unmanagedSourceDirectories).value,
21932192
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
21942193
Compile / compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions", "-nowarn"),
2195-
Compile / compile / scalacOptions += "-Yno-stdlib-patches",
21962194
Compile / compile / scalacOptions += "-Yexplicit-nulls",
21972195
Compile / compile / scalacOptions += "-scalajs",
21982196
// Configure the source maps to point to GitHub for releases

0 commit comments

Comments
 (0)