diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index a7108ef157a7..8c30c54b1dbc 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -223,21 +223,21 @@ class Definitions { else NoSymbol) cls } - @threadUnsafe lazy val ScalaPackageObject: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.package")) + @threadUnsafe lazy val ScalaPackageObjectRef: TermRef = ctx.requiredModuleRef("scala.package") @threadUnsafe lazy val JavaPackageVal: TermSymbol = ctx.requiredPackage(nme.java) @threadUnsafe lazy val JavaLangPackageVal: TermSymbol = ctx.requiredPackage(jnme.JavaLang) - // fundamental modules - @threadUnsafe lazy val SysPackage : SymbolPerRun = perRun(ctx.requiredModuleRef("scala.sys.package")) + @threadUnsafe lazy val SysPackage: TermSymbol = ctx.requiredModule("scala.sys.package") @threadUnsafe lazy val Sys_error: SymbolPerRun = perRun(SysPackage.moduleClass.requiredMethodRef(nme.error)) @threadUnsafe lazy val ScalaXmlPackageClass: Symbol = ctx.getPackageClassIfDefined("scala.xml") - @threadUnsafe lazy val CompiletimePackageObject: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.compiletime.package")) - @threadUnsafe lazy val Compiletime_error : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef(nme.error)) - @threadUnsafe lazy val Compiletime_constValue : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("constValue")) - @threadUnsafe lazy val Compiletime_constValueOpt: SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("constValueOpt")) - @threadUnsafe lazy val Compiletime_code : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("code")) + @threadUnsafe lazy val CompiletimePackageObjectRef: TermRef = ctx.requiredModuleRef("scala.compiletime.package") + @threadUnsafe lazy val CompiletimePackageObject: Symbol = CompiletimePackageObjectRef.symbol.moduleClass + @threadUnsafe lazy val Compiletime_error : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef(nme.error)) + @threadUnsafe lazy val Compiletime_constValue : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("constValue")) + @threadUnsafe lazy val Compiletime_constValueOpt: SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("constValueOpt")) + @threadUnsafe lazy val Compiletime_code : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("code")) /** The `scalaShadowing` package is used to safely modify classes and * objects in scala so that they can be used from dotty. They will @@ -246,7 +246,8 @@ class Definitions { * in `scalaShadowing` so they don't clash with the same-named `scala` * members at runtime. */ - @threadUnsafe lazy val ScalaShadowingPackage: TermSymbol = ctx.requiredPackage(nme.scalaShadowing) + @threadUnsafe lazy val ScalaShadowingPackageVal: TermSymbol = ctx.requiredPackage(nme.scalaShadowing) + def ScalaShadowingPackageClass(implicit ctx: Context): ClassSymbol = 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 @@ -363,7 +364,8 @@ class Definitions { def ImplicitScrutineeTypeRef: TypeRef = ImplicitScrutineeTypeSym.typeRef - @threadUnsafe lazy val ScalaPredefModule: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.Predef")) + @threadUnsafe lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef") + def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol @threadUnsafe lazy val Predef_conforms : SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.conforms_)) @threadUnsafe lazy val Predef_classOf : SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.classOf)) @threadUnsafe lazy val Predef_undefined: SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.???)) @@ -380,11 +382,13 @@ class Definitions { else ScalaPredefModule.requiredClass("DummyImplicit") - @threadUnsafe lazy val ScalaRuntimeModule: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.runtime.ScalaRunTime")) + @threadUnsafe lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime") + def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass def runtimeMethodRef(name: PreName): TermRef = ScalaRuntimeModule.requiredMethodRef(name) - def ScalaRuntime_drop: SymbolPerRun = perRun(runtimeMethodRef(nme.drop)) + def ScalaRuntime_dropR(implicit ctx: Context): TermRef = runtimeMethodRef(nme.drop) + def ScalaRuntime_drop(implicit ctx: Context): Symbol = ScalaRuntime_dropR.symbol @threadUnsafe lazy val BoxesRunTimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime") def BoxesRunTimeModule(implicit ctx: Context): Symbol = BoxesRunTimeModuleRef.symbol @@ -1025,7 +1029,7 @@ class Definitions { } final def isCompiletime_S(sym: Symbol)(implicit ctx: Context): Boolean = - sym.name == tpnme.S && sym.owner == CompiletimePackageObject.moduleClass + sym.name == tpnme.S && sym.owner == CompiletimePackageObject // ----- Symbol sets --------------------------------------------------- @@ -1185,8 +1189,8 @@ class Definitions { ) val PredefImportFns: List[() => TermRef] = List[() => TermRef]( - () => ScalaPredefModule.termRef, - () => DottyPredefModule.termRef + () => ScalaPredefModuleRef, + () => DottyPredefModuleRef ) @threadUnsafe lazy val RootImportFns: List[() => TermRef] = @@ -1463,7 +1467,7 @@ class Definitions { this.ctx = ctx if (!isInitialized) { // Enter all symbols from the scalaShadowing package in the scala package - for (m <- ScalaShadowingPackage.info.decls) + for (m <- ScalaShadowingPackageClass.info.decls) ScalaPackageClass.enter(m) // force initialization of every symbol that is synthesized or hijacked by the compiler diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index dfe98be4c0f0..bcd4eb058f91 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -176,7 +176,7 @@ 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) { + if (classRoot.owner == defn.ScalaShadowingPackageClass) { // Symbols in scalaShadowing are also added to scala defn.ScalaPackageClass.delete(sym) } diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 1a874d0df76f..b5fc8830d328 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -125,8 +125,8 @@ class PlainPrinter(_ctx: Context) extends Printer { * They are either aliased in scala.Predef or in the scala package object. */ private[this] lazy val printWithoutPrefix: Set[Symbol] = - (defn.ScalaPredefModule.termRef.typeAliasMembers - ++ defn.ScalaPackageObject.termRef.typeAliasMembers).map(_.info.classSymbol).toSet + (defn.ScalaPredefModuleRef.typeAliasMembers + ++ defn.ScalaPackageObjectRef.typeAliasMembers).map(_.info.classSymbol).toSet def toText(tp: Type): Text = controlled { homogenize(tp) match { diff --git a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala index f4cbaceffb1d..e79c03cc9974 100644 --- a/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala +++ b/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala @@ -50,9 +50,9 @@ trait QuotesAndSplices { self: Typer => case quoted => ctx.compilationUnit.needsStaging = true val tree1 = - if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuote.termRef), quoted :: Nil), pt)(quoteContext) + if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuoteR), quoted :: Nil), pt)(quoteContext) else if (ctx.mode.is(Mode.Pattern) && level == 0) typedQuotePattern(quoted, pt, qctx) - else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), quoted), pt)(quoteContext) + else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuoteR), quoted), pt)(quoteContext) tree1.withSpan(tree.span) } } @@ -88,7 +88,7 @@ trait QuotesAndSplices { self: Typer => else if (!c.outer.owner.is(Package)) markAsMacro(c.outer) markAsMacro(ctx) } - typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSplice.termRef), tree.expr), pt)(spliceContext).withSpan(tree.span) + typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSpliceR), tree.expr), pt)(spliceContext).withSpan(tree.span) } } } @@ -181,7 +181,7 @@ trait QuotesAndSplices { self: Typer => val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprType), tpt1 :: Nil) transform(Splice(Typed(pat, exprTpt))) case Splice(pat) => - try ref(defn.InternalQuoted_patternHole.termRef).appliedToType(tree.tpe).withSpan(tree.span) + try ref(defn.InternalQuoted_patternHoleR).appliedToType(tree.tpe).withSpan(tree.span) finally { val patType = pat.tpe.widen val patType1 = patType.underlyingIfRepeated(isJava = false) @@ -350,9 +350,9 @@ trait QuotesAndSplices { self: Typer => val splicePat = typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType) UnApply( - fun = ref(defn.InternalQuotedMatcher_unapply.termRef).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil), + fun = ref(defn.InternalQuotedMatcher_unapplyR).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil), implicits = - ref(defn.InternalQuoted_exprQuote.termRef).appliedToType(shape.tpe).appliedTo(shape) :: + ref(defn.InternalQuoted_exprQuoteR).appliedToType(shape.tpe).appliedTo(shape) :: Literal(Constant(typeBindings.nonEmpty)) :: qctx :: Nil, patterns = splicePat :: Nil,