Skip to content

Remove scalaShadowing from the compiler #10708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,6 @@ class Definitions {
@tu lazy val CompiletimeOpsPackageObjectString: Symbol = requiredModule("scala.compiletime.ops.package.string")
@tu lazy val CompiletimeOpsPackageObjectBoolean: Symbol = requiredModule("scala.compiletime.ops.package.boolean")

/** The `scalaShadowing` package is used to safely modify classes and
* objects in scala so that they can be used from dotty. They will
* be visible as members of the `scala` package, replacing any objects
* or classes with the same name. But their binary artifacts are
* in `scalaShadowing` so they don't clash with the same-named `scala`
* members at runtime.
* It is used only for non-bootstrapped code
*/
@tu lazy val ScalaShadowingPackage: TermSymbol = requiredPackage(nme.scalaShadowing)

/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
* because after erasure the Any and AnyVal references get remapped to the Object methods
* which would result in a double binding assertion failure.
Expand Down Expand Up @@ -1299,9 +1289,6 @@ class Definitions {
def isBoxedUnitClass(cls: Symbol): Boolean =
cls.isClass && (cls.owner eq ScalaRuntimePackageClass) && cls.name == tpnme.BoxedUnit

def isScalaShadowingPackageClass(cls: Symbol): Boolean =
cls.name == tpnme.scalaShadowing && cls.owner == RootClass

/** Returns the erased class of the function class `cls`
* - FunctionN for N > 22 becomes FunctionXXL
* - FunctionN for 22 > N >= 0 remains as FunctionN
Expand Down Expand Up @@ -1738,10 +1725,6 @@ class Definitions {
def init()(using Context): Unit = {
this.initCtx = ctx
if (!isInitialized) {
// Enter all symbols from the scalaShadowing package in the scala package
for (m <- ScalaShadowingPackage.info.decls)
ScalaPackageClass.enter(m)

// force initialization of every symbol that is synthesized or hijacked by the compiler
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass

Expand Down
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,8 @@ object Denotations {
def select(prefix: Denotation, selector: Name): Denotation = {
val owner = prefix.disambiguate(_.info.isParameterless)
def isPackageFromCoreLibMissing: Boolean =
owner.symbol == defn.RootClass &&
(
selector == nme.scala || // if the scala package is missing, the stdlib must be missing
selector == nme.scalaShadowing // if the scalaShadowing package is missing, the dotty library must be missing
)
// if the scala package is missing, the stdlib must be missing
owner.symbol == defn.RootClass && selector == nme.scala
if (owner.exists) {
val result = if (isPackage) owner.info.decl(selector) else owner.info.member(selector)
if (result.exists) result
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ object StdNames {
val classOf: N = "classOf"
val clone_ : N = "clone"
val common: N = "common"
val compiletime : N = "compiletime"
val conforms_ : N = "$conforms"
val copy: N = "copy"
val currentMirror: N = "currentMirror"
Expand Down Expand Up @@ -572,7 +573,6 @@ object StdNames {
val s: N = "s"
val sameElements: N = "sameElements"
val scala : N = "scala"
val scalaShadowing : N = "scalaShadowing"
val selectDynamic: N = "selectDynamic"
val selectOverloadedMethod: N = "selectOverloadedMethod"
val selectTerm: N = "selectTerm"
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,6 @@ object SymDenotations {
val nxt = this.nextInRun
if (nxt.validFor.code > this.validFor.code)
this.nextInRun.asSymDenotation.asClass.enter(sym)
if (defn.isScalaShadowingPackageClass(sym.owner))
defn.ScalaPackageClass.enter(sym) // ScalaShadowing members are mirrored in ScalaPackage
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ class ClassfileParser(
else if (result == Some(NoEmbedded))
for (sym <- List(moduleRoot.sourceModule, moduleRoot.symbol, classRoot.symbol)) {
classRoot.owner.asClass.delete(sym)
if (classRoot.owner == defn.ScalaShadowingPackage.moduleClass)
// Symbols in scalaShadowing are also added to scala
defn.ScalaPackageClass.delete(sym)
sym.markAbsent()
}

Expand Down
4 changes: 3 additions & 1 deletion compiler/test/dotty/tools/dotc/MissingCoreLibTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class MissingCoreLibTests {
val reporter = Main.process(options)
assertEquals(1, reporter.errorCount)
val errorMessage = reporter.allErrors.head.message
assertTrue(errorMessage.contains("Make sure the compiler core libraries are on the classpath"))
// FIXME: We currently only detect if the scala library is missing but not the dotty library.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will open an issue referencing this once it is merged

// See dotty.tools.dotc.MissingCoreLibraryException
// assertTrue(errorMessage.contains("Make sure the compiler core libraries are on the classpath"))
}

}