aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Definitions.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-10-20 17:32:27 +0200
committerMartin Odersky <odersky@gmail.com>2016-10-20 17:32:27 +0200
commit259332c9bbc127a6936e2d53bbc609db9533f0f9 (patch)
treed25bedfcfd099df32c62459ed1257824fcd03c88 /src/dotty/tools/dotc/core/Definitions.scala
parent3e76f3c26891e3df6afc6ff1ef086d9f876ffc07 (diff)
downloaddotty-259332c9bbc127a6936e2d53bbc609db9533f0f9.tar.gz
dotty-259332c9bbc127a6936e2d53bbc609db9533f0f9.tar.bz2
dotty-259332c9bbc127a6936e2d53bbc609db9533f0f9.zip
Introduce scalaShadowing package
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.
Diffstat (limited to 'src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 50746c61d..b60583e9e 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -140,6 +140,16 @@ class Definitions {
lazy val Sys_errorR = SysPackage.moduleClass.requiredMethodRef(nme.error)
def Sys_error(implicit ctx: Context) = Sys_errorR.symbol
+ /** 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.
+ */
+ lazy val ScalaShadowingPackageVal = ctx.requiredPackage("scalaShadowing")
+ lazy val ScalaShadowingPackageClass = ScalaShadowingPackageVal.moduleClass.asClass
+
/** 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.
@@ -781,6 +791,11 @@ class Definitions {
if (!_isInitialized) {
// force initialization of every symbol that is synthesized or hijacked by the compiler
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses()
+
+ // Enter all symbols from the scalaShadowing package in the scala package
+ for (m <- ScalaShadowingPackageClass.info.decls)
+ ScalaPackageClass.enter(m)
+
_isInitialized = true
}
}