Skip to content

Commit 2cee5a7

Browse files
committed
Separate reload logic from WithFixedSym
1 parent 8d8491a commit 2cee5a7

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ object SymDenotations {
453453
(this is (ModuleVal, butNot = Package)) && moduleClass.isAbsent
454454
}
455455

456+
final def isValidInCurrentRun(implicit ctx: Context): Boolean =
457+
validFor.runId == ctx.runId || ctx.stillValid(this)
458+
459+
final def isReferencedSymbolically(implicit ctx: Context) =
460+
(this is NonMember) || isTerm && ctx.phase.symbolicRefs
461+
456462
/** Is this symbol the root class or its companion object? */
457463
final def isRoot: Boolean =
458464
(name.toTermName == nme.ROOT || name == nme.ROOTPKG) && (owner eq NoSymbol)

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ object Symbols {
425425
}
426426

427427
final def isValidInCurrentRun(implicit ctx: Context): Boolean =
428-
lastDenot.validFor.runId == ctx.runId || ctx.stillValid(lastDenot)
428+
lastDenot.isValidInCurrentRun
429429

430430
/** Subclass tests and casts */
431431
final def isTerm(implicit ctx: Context): Boolean =
@@ -440,10 +440,8 @@ object Symbols {
440440
final def asType(implicit ctx: Context): TypeSymbol = { assert(isType, s"isType called on not-a-Type $this"); asInstanceOf[TypeSymbol] }
441441
final def asClass: ClassSymbol = asInstanceOf[ClassSymbol]
442442

443-
final def isReferencedSymbolically(implicit ctx: Context) = {
444-
val sym = lastDenot
445-
sym != null && ((sym is NonMember) || sym.isTerm && ctx.phase.symbolicRefs)
446-
}
443+
final def isReferencedSymbolically(implicit ctx: Context) =
444+
lastDenot != null && lastDenot.isReferencedSymbolically
447445

448446
/** Special cased here, because it may be used on naked symbols in substituters */
449447
final def isStatic(implicit ctx: Context): Boolean =

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,12 @@ object Types {
15621562
}
15631563
}
15641564

1565+
private def keepSymbol(d: SymDenotation)(implicit ctx: Context) =
1566+
d.is(Private) ||
1567+
d.isConstructor ||
1568+
d.isReferencedSymbolically ||
1569+
d.exists && (d.owner.isTerm || prefix.isTightPrefix(d.owner))
1570+
15651571
/** A second fallback to recompute the denotation if necessary */
15661572
private def computeDenot(implicit ctx: Context): Denotation = {
15671573
val savedEphemeral = ctx.typerState.ephemeral
@@ -1572,9 +1578,8 @@ object Types {
15721578
val sym = lastSymbol
15731579
if (sym != null && sym.isValidInCurrentRun) denotOfSym(sym) else loadDenot
15741580
case d: SymDenotation =>
1575-
if (this.isInstanceOf[WithFixedSym]) d.current
1576-
else if (d.validFor.runId == ctx.runId || ctx.stillValid(d))
1577-
if (d.exists && prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
1581+
if (d.isValidInCurrentRun)
1582+
if (keepSymbol(d)) d.current
15781583
else recomputeMember(d) // symbol could have been overridden, recompute membership
15791584
else {
15801585
val newd = loadDenot

0 commit comments

Comments
 (0)