Skip to content

Commit d4dcb90

Browse files
committed
Fix #2395: Check if the scala or dotty libraries are missing
1 parent 8ca8cd9 commit d4dcb90

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dotty.tools.dotc
2+
3+
import dotty.tools.FatalError
4+
5+
class MissingCoreLibraryException(rootPackage: String) extends FatalError(
6+
s"""Could not find package $rootPackage from compiler core libraries.
7+
|Make sure the compiler core libraries are on the classpath.
8+
""".stripMargin
9+
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class Definitions {
212212
* in `scalaShadowing` so they don't clash with the same-named `scala`
213213
* members at runtime.
214214
*/
215-
lazy val ScalaShadowingPackageVal = ctx.requiredPackage("scalaShadowing")
215+
lazy val ScalaShadowingPackageVal = ctx.requiredPackage(nme.scalaShadowing)
216216
lazy val ScalaShadowingPackageClass = ScalaShadowingPackageVal.moduleClass.asClass
217217

218218
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,10 @@ object Denotations {
11991199
val alt =
12001200
if (generateStubs) missingHook(owner.symbol.moduleClass, selector)
12011201
else NoSymbol
1202-
if (alt.exists) alt.denot else MissingRef(owner, selector)
1202+
if (alt.exists) alt.denot
1203+
else if (owner.symbol == defn.RootClass && (selector == nme.scala_ || selector == nme.scalaShadowing))
1204+
throw new MissingCoreLibraryException(selector.toString)
1205+
else MissingRef(owner, selector)
12031206
}
12041207
}
12051208
else owner

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ object StdNames {
491491
val runtimeMirror: N = "runtimeMirror"
492492
val sameElements: N = "sameElements"
493493
val scala_ : N = "scala"
494+
val scalaShadowing : N = "scalaShadowing"
494495
val selectDynamic: N = "selectDynamic"
495496
val selectDynamicMethod: N = "selectDynamicMethod"
496497
val selectOverloadedMethod: N = "selectOverloadedMethod"

0 commit comments

Comments
 (0)