Skip to content

Commit 5e2fd1f

Browse files
committed
Use perRun for Definition members #2 (reverted from commit 2bac1fe)
1 parent c6b1fa2 commit 5e2fd1f

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,21 @@ class Definitions {
223223
else NoSymbol)
224224
cls
225225
}
226-
@threadUnsafe lazy val ScalaPackageObject: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.package"))
226+
@threadUnsafe lazy val ScalaPackageObjectRef: TermRef = ctx.requiredModuleRef("scala.package")
227227
@threadUnsafe lazy val JavaPackageVal: TermSymbol = ctx.requiredPackage(nme.java)
228228
@threadUnsafe lazy val JavaLangPackageVal: TermSymbol = ctx.requiredPackage(jnme.JavaLang)
229-
230229
// fundamental modules
231-
@threadUnsafe lazy val SysPackage : SymbolPerRun = perRun(ctx.requiredModuleRef("scala.sys.package"))
230+
@threadUnsafe lazy val SysPackage: TermSymbol = ctx.requiredModule("scala.sys.package")
232231
@threadUnsafe lazy val Sys_error: SymbolPerRun = perRun(SysPackage.moduleClass.requiredMethodRef(nme.error))
233232

234233
@threadUnsafe lazy val ScalaXmlPackageClass: Symbol = ctx.getPackageClassIfDefined("scala.xml")
235234

236-
@threadUnsafe lazy val CompiletimePackageObject: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.compiletime.package"))
237-
@threadUnsafe lazy val Compiletime_error : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef(nme.error))
238-
@threadUnsafe lazy val Compiletime_constValue : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("constValue"))
239-
@threadUnsafe lazy val Compiletime_constValueOpt: SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("constValueOpt"))
240-
@threadUnsafe lazy val Compiletime_code : SymbolPerRun = perRun(CompiletimePackageObject.requiredMethodRef("code"))
235+
@threadUnsafe lazy val CompiletimePackageObjectRef: TermRef = ctx.requiredModuleRef("scala.compiletime.package")
236+
@threadUnsafe lazy val CompiletimePackageObject: Symbol = CompiletimePackageObjectRef.symbol.moduleClass
237+
@threadUnsafe lazy val Compiletime_error : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef(nme.error))
238+
@threadUnsafe lazy val Compiletime_constValue : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("constValue"))
239+
@threadUnsafe lazy val Compiletime_constValueOpt: SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("constValueOpt"))
240+
@threadUnsafe lazy val Compiletime_code : SymbolPerRun = perRun(CompiletimePackageObjectRef.symbol.requiredMethodRef("code"))
241241

242242
/** The `scalaShadowing` package is used to safely modify classes and
243243
* objects in scala so that they can be used from dotty. They will
@@ -246,7 +246,8 @@ class Definitions {
246246
* in `scalaShadowing` so they don't clash with the same-named `scala`
247247
* members at runtime.
248248
*/
249-
@threadUnsafe lazy val ScalaShadowingPackage: TermSymbol = ctx.requiredPackage(nme.scalaShadowing)
249+
@threadUnsafe lazy val ScalaShadowingPackageVal: TermSymbol = ctx.requiredPackage(nme.scalaShadowing)
250+
def ScalaShadowingPackageClass(implicit ctx: Context): ClassSymbol = ScalaShadowingPackageVal.moduleClass.asClass
250251

251252
/** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter)
252253
* because after erasure the Any and AnyVal references get remapped to the Object methods
@@ -363,7 +364,8 @@ class Definitions {
363364
def ImplicitScrutineeTypeRef: TypeRef = ImplicitScrutineeTypeSym.typeRef
364365

365366

366-
@threadUnsafe lazy val ScalaPredefModule: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.Predef"))
367+
@threadUnsafe lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef")
368+
def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol
367369
@threadUnsafe lazy val Predef_conforms : SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.conforms_))
368370
@threadUnsafe lazy val Predef_classOf : SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.classOf))
369371
@threadUnsafe lazy val Predef_undefined: SymbolPerRun = perRun(ScalaPredefModule.requiredMethodRef(nme.???))
@@ -380,11 +382,13 @@ class Definitions {
380382
else
381383
ScalaPredefModule.requiredClass("DummyImplicit")
382384

383-
@threadUnsafe lazy val ScalaRuntimeModule: SymbolPerRun = perRun(ctx.requiredModuleRef("scala.runtime.ScalaRunTime"))
385+
@threadUnsafe lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime")
386+
def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol
384387
def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass
385388

386389
def runtimeMethodRef(name: PreName): TermRef = ScalaRuntimeModule.requiredMethodRef(name)
387-
def ScalaRuntime_drop: SymbolPerRun = perRun(runtimeMethodRef(nme.drop))
390+
def ScalaRuntime_dropR(implicit ctx: Context): TermRef = runtimeMethodRef(nme.drop)
391+
def ScalaRuntime_drop(implicit ctx: Context): Symbol = ScalaRuntime_dropR.symbol
388392

389393
@threadUnsafe lazy val BoxesRunTimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime")
390394
def BoxesRunTimeModule(implicit ctx: Context): Symbol = BoxesRunTimeModuleRef.symbol
@@ -1025,7 +1029,7 @@ class Definitions {
10251029
}
10261030

10271031
final def isCompiletime_S(sym: Symbol)(implicit ctx: Context): Boolean =
1028-
sym.name == tpnme.S && sym.owner == CompiletimePackageObject.moduleClass
1032+
sym.name == tpnme.S && sym.owner == CompiletimePackageObject
10291033

10301034
// ----- Symbol sets ---------------------------------------------------
10311035

@@ -1185,8 +1189,8 @@ class Definitions {
11851189
)
11861190

11871191
val PredefImportFns: List[() => TermRef] = List[() => TermRef](
1188-
() => ScalaPredefModule.termRef,
1189-
() => DottyPredefModule.termRef
1192+
() => ScalaPredefModuleRef,
1193+
() => DottyPredefModuleRef
11901194
)
11911195

11921196
@threadUnsafe lazy val RootImportFns: List[() => TermRef] =
@@ -1463,7 +1467,7 @@ class Definitions {
14631467
this.ctx = ctx
14641468
if (!isInitialized) {
14651469
// Enter all symbols from the scalaShadowing package in the scala package
1466-
for (m <- ScalaShadowingPackage.info.decls)
1470+
for (m <- ScalaShadowingPackageClass.info.decls)
14671471
ScalaPackageClass.enter(m)
14681472

14691473
// force initialization of every symbol that is synthesized or hijacked by the compiler

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ClassfileParser(
176176
} else if (result == Some(NoEmbedded)) {
177177
for (sym <- List(moduleRoot.sourceModule, moduleRoot.symbol, classRoot.symbol)) {
178178
classRoot.owner.asClass.delete(sym)
179-
if (classRoot.owner == defn.ScalaShadowingPackage.moduleClass) {
179+
if (classRoot.owner == defn.ScalaShadowingPackageClass) {
180180
// Symbols in scalaShadowing are also added to scala
181181
defn.ScalaPackageClass.delete(sym)
182182
}

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
125125
* They are either aliased in scala.Predef or in the scala package object.
126126
*/
127127
private[this] lazy val printWithoutPrefix: Set[Symbol] =
128-
(defn.ScalaPredefModule.termRef.typeAliasMembers
129-
++ defn.ScalaPackageObject.termRef.typeAliasMembers).map(_.info.classSymbol).toSet
128+
(defn.ScalaPredefModuleRef.typeAliasMembers
129+
++ defn.ScalaPackageObjectRef.typeAliasMembers).map(_.info.classSymbol).toSet
130130

131131
def toText(tp: Type): Text = controlled {
132132
homogenize(tp) match {

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ trait QuotesAndSplices { self: Typer =>
5050
case quoted =>
5151
ctx.compilationUnit.needsStaging = true
5252
val tree1 =
53-
if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuote.termRef), quoted :: Nil), pt)(quoteContext)
53+
if (quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuoteR), quoted :: Nil), pt)(quoteContext)
5454
else if (ctx.mode.is(Mode.Pattern) && level == 0) typedQuotePattern(quoted, pt, qctx)
55-
else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), quoted), pt)(quoteContext)
55+
else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuoteR), quoted), pt)(quoteContext)
5656
tree1.withSpan(tree.span)
5757
}
5858
}
@@ -88,7 +88,7 @@ trait QuotesAndSplices { self: Typer =>
8888
else if (!c.outer.owner.is(Package)) markAsMacro(c.outer)
8989
markAsMacro(ctx)
9090
}
91-
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSplice.termRef), tree.expr), pt)(spliceContext).withSpan(tree.span)
91+
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprSpliceR), tree.expr), pt)(spliceContext).withSpan(tree.span)
9292
}
9393
}
9494
}
@@ -181,7 +181,7 @@ trait QuotesAndSplices { self: Typer =>
181181
val exprTpt = AppliedTypeTree(TypeTree(defn.QuotedExprType), tpt1 :: Nil)
182182
transform(Splice(Typed(pat, exprTpt)))
183183
case Splice(pat) =>
184-
try ref(defn.InternalQuoted_patternHole.termRef).appliedToType(tree.tpe).withSpan(tree.span)
184+
try ref(defn.InternalQuoted_patternHoleR).appliedToType(tree.tpe).withSpan(tree.span)
185185
finally {
186186
val patType = pat.tpe.widen
187187
val patType1 = patType.underlyingIfRepeated(isJava = false)
@@ -350,9 +350,9 @@ trait QuotesAndSplices { self: Typer =>
350350
val splicePat = typed(untpd.Tuple(splices.map(x => untpd.TypedSplice(replaceBindingsInTree.transform(x)))).withSpan(quoted.span), patType)
351351

352352
UnApply(
353-
fun = ref(defn.InternalQuotedMatcher_unapply.termRef).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
353+
fun = ref(defn.InternalQuotedMatcher_unapplyR).appliedToTypeTrees(typeBindingsTuple :: TypeTree(patType) :: Nil),
354354
implicits =
355-
ref(defn.InternalQuoted_exprQuote.termRef).appliedToType(shape.tpe).appliedTo(shape) ::
355+
ref(defn.InternalQuoted_exprQuoteR).appliedToType(shape.tpe).appliedTo(shape) ::
356356
Literal(Constant(typeBindings.nonEmpty)) ::
357357
qctx :: Nil,
358358
patterns = splicePat :: Nil,

0 commit comments

Comments
 (0)