Skip to content

Commit 3b8240a

Browse files
committed
drop -Yno-stdlib-patches setting
1 parent b2850be commit 3b8240a

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
@@ -410,7 +410,6 @@ private sealed trait YSettings:
410410
val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during")
411411
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
412412
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
413-
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)
414413

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

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

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

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

15711461
@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
@@ -1779,7 +1779,6 @@ class Namer { typer: Typer =>
17791779
cls.setStableConstructor()
17801780
enterParentRefinementSyms(parentRefinements.toList)
17811781
processExports(using localCtx)
1782-
defn.patchStdLibClass(cls)
17831782
addConstructorProxies(cls)
17841783
cleanup()
17851784
}

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
@@ -1330,7 +1330,6 @@ object Build {
13301330
// Add the source directories for the stdlib (non-boostrapped)
13311331
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
13321332
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
1333-
Compile / compile / scalacOptions += "-Yno-stdlib-patches",
13341333
Compile / compile / scalacOptions ++= Seq(
13351334
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
13361335
"-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator),
@@ -1464,7 +1463,6 @@ object Build {
14641463
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
14651464
Compile / unmanagedSourceDirectories ++=
14661465
(`scala-library-bootstrapped` / Compile / unmanagedSourceDirectories).value,
1467-
Compile / compile / scalacOptions += "-Yno-stdlib-patches",
14681466
// Configure the source maps to point to GitHub for releases
14691467
Compile / compile / scalacOptions ++= {
14701468
if (isRelease) {

0 commit comments

Comments
 (0)