@@ -140,6 +140,16 @@ class Definitions {
140
140
lazy val Sys_errorR = SysPackage .moduleClass.requiredMethodRef(nme.error)
141
141
def Sys_error (implicit ctx : Context ) = Sys_errorR .symbol
142
142
143
+ /** The `scalaShadowing` package is used to safely modify classes and
144
+ * objects in scala so that they can be used from dotty. They will
145
+ * be visible as members of the `scala` package, replacing any objects
146
+ * or classes with the same name. But their binary artifacts are
147
+ * in `scalaShadowing` so they don't clash with the same-named `scala`
148
+ * members at runtime.
149
+ */
150
+ lazy val ScalaShadowingPackageVal = ctx.requiredPackage(" scalaShadowing" )
151
+ lazy val ScalaShadowingPackageClass = ScalaShadowingPackageVal .moduleClass.asClass
152
+
143
153
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
144
154
* because after erasure the Any and AnyVal references get remapped to the Object methods
145
155
* which would result in a double binding assertion failure.
@@ -410,8 +420,6 @@ class Definitions {
410
420
lazy val StringAdd_plusR = StringAddClass .requiredMethodRef(nme.raw.PLUS )
411
421
def StringAdd_+ (implicit ctx : Context ) = StringAdd_plusR .symbol
412
422
413
- lazy val PairType : TypeRef = ctx.requiredClassRef(" dotty.Pair" )
414
- def PairClass (implicit ctx : Context ) = PairType .symbol.asClass
415
423
lazy val PartialFunctionType : TypeRef = ctx.requiredClassRef(" scala.PartialFunction" )
416
424
def PartialFunctionClass (implicit ctx : Context ) = PartialFunctionType .symbol.asClass
417
425
lazy val AbstractPartialFunctionType : TypeRef = ctx.requiredClassRef(" scala.runtime.AbstractPartialFunction" )
@@ -450,37 +458,37 @@ class Definitions {
450
458
def StaticAnnotationClass (implicit ctx : Context ) = StaticAnnotationType .symbol.asClass
451
459
452
460
// Annotation classes
453
- lazy val AliasAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.Alias" )
461
+ lazy val AliasAnnotType = ctx.requiredClassRef(" scala .annotation.internal.Alias" )
454
462
def AliasAnnot (implicit ctx : Context ) = AliasAnnotType .symbol.asClass
455
- lazy val AnnotationDefaultAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.AnnotationDefault" )
463
+ lazy val AnnotationDefaultAnnotType = ctx.requiredClassRef(" scala .annotation.internal.AnnotationDefault" )
456
464
def AnnotationDefaultAnnot (implicit ctx : Context ) = AnnotationDefaultAnnotType .symbol.asClass
457
- lazy val BodyAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.Body" )
465
+ lazy val BodyAnnotType = ctx.requiredClassRef(" scala .annotation.internal.Body" )
458
466
def BodyAnnot (implicit ctx : Context ) = BodyAnnotType .symbol.asClass
459
- lazy val ChildAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.Child" )
467
+ lazy val ChildAnnotType = ctx.requiredClassRef(" scala .annotation.internal.Child" )
460
468
def ChildAnnot (implicit ctx : Context ) = ChildAnnotType .symbol.asClass
461
- lazy val CovariantBetweenAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.CovariantBetween" )
469
+ lazy val CovariantBetweenAnnotType = ctx.requiredClassRef(" scala .annotation.internal.CovariantBetween" )
462
470
def CovariantBetweenAnnot (implicit ctx : Context ) = CovariantBetweenAnnotType .symbol.asClass
463
- lazy val ContravariantBetweenAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.ContravariantBetween" )
471
+ lazy val ContravariantBetweenAnnotType = ctx.requiredClassRef(" scala .annotation.internal.ContravariantBetween" )
464
472
def ContravariantBetweenAnnot (implicit ctx : Context ) = ContravariantBetweenAnnotType .symbol.asClass
465
473
lazy val DeprecatedAnnotType = ctx.requiredClassRef(" scala.deprecated" )
466
474
def DeprecatedAnnot (implicit ctx : Context ) = DeprecatedAnnotType .symbol.asClass
467
475
lazy val ImplicitNotFoundAnnotType = ctx.requiredClassRef(" scala.annotation.implicitNotFound" )
468
476
def ImplicitNotFoundAnnot (implicit ctx : Context ) = ImplicitNotFoundAnnotType .symbol.asClass
469
477
lazy val InlineAnnotType = ctx.requiredClassRef(" scala.inline" )
470
478
def InlineAnnot (implicit ctx : Context ) = InlineAnnotType .symbol.asClass
471
- lazy val InlineParamAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.InlineParam" )
479
+ lazy val InlineParamAnnotType = ctx.requiredClassRef(" scala .annotation.internal.InlineParam" )
472
480
def InlineParamAnnot (implicit ctx : Context ) = InlineParamAnnotType .symbol.asClass
473
- lazy val InvariantBetweenAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.InvariantBetween" )
481
+ lazy val InvariantBetweenAnnotType = ctx.requiredClassRef(" scala .annotation.internal.InvariantBetween" )
474
482
def InvariantBetweenAnnot (implicit ctx : Context ) = InvariantBetweenAnnotType .symbol.asClass
475
483
lazy val MigrationAnnotType = ctx.requiredClassRef(" scala.annotation.migration" )
476
484
def MigrationAnnot (implicit ctx : Context ) = MigrationAnnotType .symbol.asClass
477
485
lazy val NativeAnnotType = ctx.requiredClassRef(" scala.native" )
478
486
def NativeAnnot (implicit ctx : Context ) = NativeAnnotType .symbol.asClass
479
487
lazy val RemoteAnnotType = ctx.requiredClassRef(" scala.remote" )
480
488
def RemoteAnnot (implicit ctx : Context ) = RemoteAnnotType .symbol.asClass
481
- lazy val RepeatedAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.Repeated" )
489
+ lazy val RepeatedAnnotType = ctx.requiredClassRef(" scala .annotation.internal.Repeated" )
482
490
def RepeatedAnnot (implicit ctx : Context ) = RepeatedAnnotType .symbol.asClass
483
- lazy val SourceFileAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.SourceFile" )
491
+ lazy val SourceFileAnnotType = ctx.requiredClassRef(" scala .annotation.internal.SourceFile" )
484
492
def SourceFileAnnot (implicit ctx : Context ) = SourceFileAnnotType .symbol.asClass
485
493
lazy val ScalaSignatureAnnotType = ctx.requiredClassRef(" scala.reflect.ScalaSignature" )
486
494
def ScalaSignatureAnnot (implicit ctx : Context ) = ScalaSignatureAnnotType .symbol.asClass
@@ -510,7 +518,7 @@ class Definitions {
510
518
def UncheckedStableAnnot (implicit ctx : Context ) = UncheckedStableAnnotType .symbol.asClass
511
519
lazy val UncheckedVarianceAnnotType = ctx.requiredClassRef(" scala.annotation.unchecked.uncheckedVariance" )
512
520
def UncheckedVarianceAnnot (implicit ctx : Context ) = UncheckedVarianceAnnotType .symbol.asClass
513
- lazy val UnsafeNonvariantAnnotType = ctx.requiredClassRef(" dotty .annotation.internal.UnsafeNonvariant" )
521
+ lazy val UnsafeNonvariantAnnotType = ctx.requiredClassRef(" scala .annotation.internal.UnsafeNonvariant" )
514
522
def UnsafeNonvariantAnnot (implicit ctx : Context ) = UnsafeNonvariantAnnotType .symbol.asClass
515
523
lazy val VolatileAnnotType = ctx.requiredClassRef(" scala.volatile" )
516
524
def VolatileAnnot (implicit ctx : Context ) = VolatileAnnotType .symbol.asClass
@@ -781,6 +789,11 @@ class Definitions {
781
789
if (! _isInitialized) {
782
790
// force initialization of every symbol that is synthesized or hijacked by the compiler
783
791
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
792
+
793
+ // Enter all symbols from the scalaShadowing package in the scala package
794
+ for (m <- ScalaShadowingPackageClass .info.decls)
795
+ ScalaPackageClass .enter(m)
796
+
784
797
_isInitialized = true
785
798
}
786
799
}
0 commit comments