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