Skip to content

Commit 1ca5920

Browse files
committed
drop -Yno-stdlib-patches setting
1 parent 3124430 commit 1ca5920

File tree

10 files changed

+8
-132
lines changed

10 files changed

+8
-132
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ private sealed trait YSettings:
406406
val Ylog: Setting[List[String]] = PhasesSetting(ForkSetting, "Ylog", "Log operations during")
407407
val YlogClasspath: Setting[Boolean] = BooleanSetting(ForkSetting, "Ylog-classpath", "Output information about what classpath is being applied.")
408408
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting(ForkSetting, "YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
409-
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)
410409

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

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

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

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

15721462
@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
@@ -1153,7 +1153,6 @@ class TreeUnpickler(reader: TastyReader,
11531153
val stats = rdr.readIndexedStats(localDummy, end)
11541154
tparams ++ vparams ++ stats
11551155
})
1156-
defn.patchStdLibClass(cls)
11571156
NamerOps.addConstructorProxies(cls)
11581157
NamerOps.addContextBoundCompanions(cls)
11591158
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
@@ -1783,7 +1783,6 @@ class Namer { typer: Typer =>
17831783
cls.setStableConstructor()
17841784
enterParentRefinementSyms(parentRefinements.toList)
17851785
processExports(using localCtx)
1786-
defn.patchStdLibClass(cls)
17871786
addConstructorProxies(cls)
17881787
cleanup()
17891788
}

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
@@ -1322,7 +1322,6 @@ object Build {
13221322
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
13231323
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
13241324
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
1325-
Compile / scalacOptions += "-Yno-stdlib-patches",
13261325
Compile / scalacOptions += "-Yexplicit-nulls",
13271326
Compile / scalacOptions ++= Seq(
13281327
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
@@ -1455,7 +1454,6 @@ object Build {
14551454
(`scala-library-bootstrapped` / Compile / unmanagedSourceDirectories).value,
14561455
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
14571456
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions", "-nowarn"),
1458-
Compile / scalacOptions += "-Yno-stdlib-patches",
14591457
Compile / scalacOptions += "-Yexplicit-nulls",
14601458
Compile / scalacOptions += "-scalajs",
14611459
// Configure the source maps to point to GitHub for releases

0 commit comments

Comments
 (0)