From 259332c9bbc127a6936e2d53bbc609db9533f0f9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 20 Oct 2016 17:32:27 +0200 Subject: 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. --- src/dotty/tools/dotc/core/Definitions.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/dotty/tools/dotc/core/Definitions.scala') 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 } } -- cgit v1.2.3