Skip to content

Commit a9bd274

Browse files
Merge pull request #10708 from dotty-staging/remove-scala-shadowing
Remove `scalaShadowing` from the compiler
2 parents f70ee5f + 0f8f86c commit a9bd274

File tree

7 files changed

+6
-29
lines changed

7 files changed

+6
-29
lines changed

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,6 @@ class Definitions {
246246
@tu lazy val CompiletimeOpsPackageObjectString: Symbol = requiredModule("scala.compiletime.ops.package.string")
247247
@tu lazy val CompiletimeOpsPackageObjectBoolean: Symbol = requiredModule("scala.compiletime.ops.package.boolean")
248248

249-
/** The `scalaShadowing` package is used to safely modify classes and
250-
* objects in scala so that they can be used from dotty. They will
251-
* be visible as members of the `scala` package, replacing any objects
252-
* or classes with the same name. But their binary artifacts are
253-
* in `scalaShadowing` so they don't clash with the same-named `scala`
254-
* members at runtime.
255-
* It is used only for non-bootstrapped code
256-
*/
257-
@tu lazy val ScalaShadowingPackage: TermSymbol = requiredPackage(nme.scalaShadowing)
258-
259249
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
260250
* because after erasure the Any and AnyVal references get remapped to the Object methods
261251
* which would result in a double binding assertion failure.
@@ -1299,9 +1289,6 @@ class Definitions {
12991289
def isBoxedUnitClass(cls: Symbol): Boolean =
13001290
cls.isClass && (cls.owner eq ScalaRuntimePackageClass) && cls.name == tpnme.BoxedUnit
13011291

1302-
def isScalaShadowingPackageClass(cls: Symbol): Boolean =
1303-
cls.name == tpnme.scalaShadowing && cls.owner == RootClass
1304-
13051292
/** Returns the erased class of the function class `cls`
13061293
* - FunctionN for N > 22 becomes FunctionXXL
13071294
* - FunctionN for 22 > N >= 0 remains as FunctionN
@@ -1738,10 +1725,6 @@ class Definitions {
17381725
def init()(using Context): Unit = {
17391726
this.initCtx = ctx
17401727
if (!isInitialized) {
1741-
// Enter all symbols from the scalaShadowing package in the scala package
1742-
for (m <- ScalaShadowingPackage.info.decls)
1743-
ScalaPackageClass.enter(m)
1744-
17451728
// force initialization of every symbol that is synthesized or hijacked by the compiler
17461729
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass
17471730

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,11 +1226,8 @@ object Denotations {
12261226
def select(prefix: Denotation, selector: Name): Denotation = {
12271227
val owner = prefix.disambiguate(_.info.isParameterless)
12281228
def isPackageFromCoreLibMissing: Boolean =
1229-
owner.symbol == defn.RootClass &&
1230-
(
1231-
selector == nme.scala || // if the scala package is missing, the stdlib must be missing
1232-
selector == nme.scalaShadowing // if the scalaShadowing package is missing, the dotty library must be missing
1233-
)
1229+
// if the scala package is missing, the stdlib must be missing
1230+
owner.symbol == defn.RootClass && selector == nme.scala
12341231
if (owner.exists) {
12351232
val result = if (isPackage) owner.info.decl(selector) else owner.info.member(selector)
12361233
if (result.exists) result

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ object StdNames {
440440
val classOf: N = "classOf"
441441
val clone_ : N = "clone"
442442
val common: N = "common"
443+
val compiletime : N = "compiletime"
443444
val conforms_ : N = "$conforms"
444445
val copy: N = "copy"
445446
val currentMirror: N = "currentMirror"
@@ -572,7 +573,6 @@ object StdNames {
572573
val s: N = "s"
573574
val sameElements: N = "sameElements"
574575
val scala : N = "scala"
575-
val scalaShadowing : N = "scalaShadowing"
576576
val selectDynamic: N = "selectDynamic"
577577
val selectOverloadedMethod: N = "selectOverloadedMethod"
578578
val selectTerm: N = "selectTerm"

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,8 +1824,6 @@ object SymDenotations {
18241824
val nxt = this.nextInRun
18251825
if (nxt.validFor.code > this.validFor.code)
18261826
this.nextInRun.asSymDenotation.asClass.enter(sym)
1827-
if (defn.isScalaShadowingPackageClass(sym.owner))
1828-
defn.ScalaPackageClass.enter(sym) // ScalaShadowing members are mirrored in ScalaPackage
18291827
}
18301828
}
18311829

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ class ClassfileParser(
200200
else if (result == Some(NoEmbedded))
201201
for (sym <- List(moduleRoot.sourceModule, moduleRoot.symbol, classRoot.symbol)) {
202202
classRoot.owner.asClass.delete(sym)
203-
if (classRoot.owner == defn.ScalaShadowingPackage.moduleClass)
204-
// Symbols in scalaShadowing are also added to scala
205-
defn.ScalaPackageClass.delete(sym)
206203
sym.markAbsent()
207204
}
208205

compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class MissingCoreLibTests {
1616
val reporter = Main.process(options)
1717
assertEquals(1, reporter.errorCount)
1818
val errorMessage = reporter.allErrors.head.message
19-
assertTrue(errorMessage.contains("Make sure the compiler core libraries are on the classpath"))
19+
// FIXME: We currently only detect if the scala library is missing but not the dotty library.
20+
// See dotty.tools.dotc.MissingCoreLibraryException
21+
// assertTrue(errorMessage.contains("Make sure the compiler core libraries are on the classpath"))
2022
}
2123

2224
}

0 commit comments

Comments
 (0)