Skip to content

Commit e3fbf30

Browse files
committed
Some renamings
1 parent 623e26f commit e3fbf30

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

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

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ object Types {
11801180
tycon.parents.map(_.subst(tycon.typeSymbol.typeParams, args))
11811181
case tp: TypeRef =>
11821182
if (tp.info.isInstanceOf[TempClassInfo]) {
1183-
tp.reloadDenot()
1183+
tp.recomputeDenot()
11841184
assert(!tp.info.isInstanceOf[TempClassInfo])
11851185
}
11861186
tp.info.parents
@@ -1639,7 +1639,7 @@ object Types {
16391639

16401640
def finish(d: Denotation) = {
16411641
if (ctx.typerState.ephemeral)
1642-
record("ephemeral cache miss: loadDenot")
1642+
record("ephemeral cache miss: memberDenot")
16431643
else if (d.exists)
16441644
// Avoid storing NoDenotations in the cache - we will not be able to recover from
16451645
// them. The situation might arise that a type has NoDenotation in some later
@@ -1654,13 +1654,13 @@ object Types {
16541654
case name: Name =>
16551655
val sym = lastSymbol
16561656
val allowPrivate = sym == null || (sym == NoSymbol) || sym.lastKnownDenotation.flagsUNSAFE.is(Private)
1657-
finish(loadDenot(name, allowPrivate))
1657+
finish(memberDenot(name, allowPrivate))
16581658
case sym: Symbol =>
16591659
val symd = sym.lastKnownDenotation
16601660
if (symd.validFor.runId != ctx.runId && !ctx.stillValid(symd))
1661-
finish(loadDenot(symd.initial.name, allowPrivate = false))
1661+
finish(memberDenot(symd.initial.name, allowPrivate = false))
16621662
else if (infoDependsOnPrefix(symd, prefix))
1663-
finish(loadDenot(symd.initial.name, allowPrivate = symd.is(Private)))
1663+
finish(memberDenot(symd.initial.name, allowPrivate = symd.is(Private)))
16641664
else
16651665
finish(symd.current)
16661666
}
@@ -1675,13 +1675,7 @@ object Types {
16751675
else lastd match {
16761676
case lastd: SymDenotation =>
16771677
if (ctx.stillValid(lastd)) finish(lastd.current)
1678-
else
1679-
try finish(loadDenot(lastd.initial.name, allowPrivate = false))
1680-
catch {
1681-
case ex: AssertionError =>
1682-
println(i"assertion failed while $this . $lastd . ${lastd.validFor} ${lastd.flagsUNSAFE}")
1683-
throw ex
1684-
}
1678+
else finish(memberDenot(lastd.initial.name, allowPrivate = false))
16851679
case _ =>
16861680
fromDesignator
16871681
}
@@ -1690,27 +1684,6 @@ object Types {
16901684
finally ctx.typerState.ephemeral |= savedEphemeral
16911685
}
16921686

1693-
private def loadDenot(name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation = {
1694-
var d = memberDenot(prefix, name, allowPrivate)
1695-
if (!d.exists && ctx.mode.is(Mode.Interactive))
1696-
d = memberDenot(prefix, name, true)
1697-
if (!d.exists && ctx.phaseId > FirstPhaseId && lastDenotation.isInstanceOf[SymDenotation])
1698-
// name has changed; try load in earlier phase and make current
1699-
d = loadDenot(name, allowPrivate)(ctx.withPhase(ctx.phaseId - 1)).current
1700-
if (d.isOverloaded)
1701-
d = disambiguate(d)
1702-
d
1703-
}
1704-
1705-
/** Reload denotation by computing the member with the reference's name as seen
1706-
* from the reference's prefix.
1707-
*/
1708-
def reloadDenot()(implicit ctx: Context) =
1709-
setDenot(loadDenot(name, allowPrivate = !symbol.exists || symbol.is(Private)))
1710-
1711-
private def memberDenot(prefix: Type, name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
1712-
if (allowPrivate) prefix.member(name) else prefix.nonPrivateMember(name)
1713-
17141687
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
17151688
val sig = currentSignature
17161689
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig") // DEBUG
@@ -1726,6 +1699,27 @@ object Types {
17261699
else d
17271700
}
17281701

1702+
private def memberDenot(name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation = {
1703+
var d = memberDenot(prefix, name, allowPrivate)
1704+
if (!d.exists && ctx.mode.is(Mode.Interactive))
1705+
d = memberDenot(prefix, name, true)
1706+
if (!d.exists && ctx.phaseId > FirstPhaseId && lastDenotation.isInstanceOf[SymDenotation])
1707+
// name has changed; try load in earlier phase and make current
1708+
d = memberDenot(name, allowPrivate)(ctx.withPhase(ctx.phaseId - 1)).current
1709+
if (d.isOverloaded)
1710+
d = disambiguate(d)
1711+
d
1712+
}
1713+
1714+
private def memberDenot(prefix: Type, name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation =
1715+
if (allowPrivate) prefix.member(name) else prefix.nonPrivateMember(name)
1716+
1717+
/** Reload denotation by computing the member with the reference's name as seen
1718+
* from the reference's prefix.
1719+
*/
1720+
def recomputeDenot()(implicit ctx: Context) =
1721+
setDenot(memberDenot(name, allowPrivate = !symbol.exists || symbol.is(Private)))
1722+
17291723
private def setDenot(denot: Denotation)(implicit ctx: Context): Unit = {
17301724
if (ctx.isAfterTyper)
17311725
assert(!denot.isOverloaded, this)
@@ -3751,7 +3745,7 @@ object Types {
37513745
def apply(tp: Type): Type
37523746

37533747
protected def derivedSelect(tp: NamedType, pre: Type): Type =
3754-
tp.derivedSelect(pre) match {
3748+
tp.derivedSelect(pre) match {
37553749
case tp: TypeArgRef if variance != 0 =>
37563750
val tp1 = tp.underlying
37573751
if (variance > 0) tp1.hiBound else tp1.loBound

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ class Namer { typer: Typer =>
12031203
// fail with a bounds error in PostTyper.
12041204
def ensureUpToDate(tp: Type, outdated: Type) = tp match {
12051205
case tref: TypeRef if tref.info == outdated && sym.info != outdated =>
1206-
tref.reloadDenot()
1206+
tref.recomputeDenot()
12071207
case _ =>
12081208
}
12091209
ensureUpToDate(sym.typeRef, dummyInfo)

0 commit comments

Comments
 (0)