Skip to content

Commit f716898

Browse files
committed
Polishings
1 parent f3f7b58 commit f716898

File tree

8 files changed

+26
-57
lines changed

8 files changed

+26
-57
lines changed

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ object Config {
148148
final val showCompletions = false
149149

150150
/** If set, enables tracing */
151-
final val tracingEnabled = true
151+
final val tracingEnabled = false
152152

153153
/** Initial capacity of uniques HashMap.
154154
* Note: This MUST BE a power of two to work with util.HashSet

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ object Phases {
321321
private[this] var myErasedTypes = false
322322
private[this] var myFlatClasses = false
323323
private[this] var myRefChecked = false
324-
private[this] var mySymbolicRefs = false
325324
private[this] var myLabelsReordered = false
326325

327326
private[this] var mySameMembersStartId = NoPhaseId
@@ -340,7 +339,6 @@ object Phases {
340339
final def erasedTypes = myErasedTypes // Phase is after erasure
341340
final def flatClasses = myFlatClasses // Phase is after flatten
342341
final def refChecked = myRefChecked // Phase is after RefChecks
343-
final def symbolicRefs = mySymbolicRefs // Phase is after ResolveSuper, newly generated TermRefs should be symbolic
344342
final def labelsReordered = myLabelsReordered // Phase is after LabelDefs, labels are flattened and owner chains don't mirror this
345343

346344
final def sameMembersStartId = mySameMembersStartId
@@ -357,7 +355,6 @@ object Phases {
357355
myErasedTypes = prev.getClass == classOf[Erasure] || prev.erasedTypes
358356
myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses
359357
myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked
360-
mySymbolicRefs = getClass == classOf[Erasure] || prev.symbolicRefs
361358
myLabelsReordered = prev.getClass == classOf[LabelDefs] || prev.labelsReordered
362359
mySameMembersStartId = if (changesMembers) id else prev.sameMembersStartId
363360
mySameParentsStartId = if (changesParents) id else prev.sameMembersStartId

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,9 +1432,10 @@ object SymDenotations {
14321432
if (classParents.isEmpty && !emptyParentsExpected)
14331433
onBehalf.signalProvisional()
14341434
val builder = new BaseDataBuilder
1435-
for (p <- classParents)
1435+
for (p <- classParents) {
1436+
assert(p.typeSymbol.isClass, s"$this has non-class parent: $p")
14361437
builder.addAll(p.typeSymbol.asClass.baseClasses)
1437-
1438+
}
14381439
(classSymbol :: builder.baseClasses, builder.baseClassSet)
14391440
}
14401441

@@ -1846,20 +1847,18 @@ object SymDenotations {
18461847
}
18471848
}
18481849

1849-
class NoDenotation(sym: Symbol, name: Name, override val exists: Boolean)
1850-
extends SymDenotation(sym, NoSymbol, name, Permanent, NoType) {
1850+
@sharable object NoDenotation
1851+
extends SymDenotation(NoSymbol, NoSymbol, "<none>".toTermName, Permanent, NoType) {
18511852
override def isType = false
1852-
override def isTerm = exists
1853+
override def isTerm = false
1854+
override def exists = false
18531855
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
18541856
override def computeAsSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = this
18551857
override def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation = this
1856-
sym.denot = this
1858+
NoSymbol.denot = this
18571859
validFor = Period.allInRun(NoRunId)
18581860
}
18591861

1860-
@sharable val NoDenotation: NoDenotation =
1861-
new NoDenotation(NoSymbol, "<none>".toTermName, exists = false)
1862-
18631862
// ---- Completion --------------------------------------------------------
18641863

18651864
/** Instances of LazyType are carried by uncompleted symbols.

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,10 @@ object Symbols {
447447
final def isValidInCurrentRun(implicit ctx: Context): Boolean =
448448
(lastDenot.validFor.runId == ctx.runId || ctx.stillValid(lastDenot)) &&
449449
(lastDenot.symbol eq this)
450-
// the last condition is needed because overwritten package members keep
451-
// denotations pointing to the new symbol, so the validity periods check out OK.
452-
// But once a package member is overridden it is not longerr valid.
450+
// the last condition is needed because under option -Yupdate-stale overwritten
451+
// package members keep denotations pointing to the new symbol, so the validity
452+
// periods check out OK. But once a package member is overridden it is not longer
453+
// valid. If the option would be removed, the check would be no longer needed.
453454

454455
final def isTerm(implicit ctx: Context): Boolean =
455456
(if (defRunId == ctx.runId) lastDenot else denot).isTerm
@@ -467,14 +468,6 @@ object Symbols {
467468
final def isClass: Boolean = isInstanceOf[ClassSymbol]
468469
final def asClass: ClassSymbol = asInstanceOf[ClassSymbol]
469470

470-
/** Test whether symbol is referenced symbolically. This
471-
* conservatively returns `false` if symbol does not yet have a denotation
472-
*/
473-
final def isReferencedSymbolically(implicit ctx: Context) = {
474-
val d = lastDenot
475-
d != null && (d.is(NonMember) || ctx.phase.symbolicRefs)
476-
}
477-
478471
/** Test whether symbol is private. This
479472
* conservatively returns `false` if symbol does not yet have a denotation, or denotation
480473
* is a class that is not yet read.

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,10 +1677,8 @@ object Types {
16771677

16781678
private def loadDenot(name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation = {
16791679
var d = memberDenot(prefix, name, allowPrivate)
1680-
if (!d.exists) {
1681-
val d1 = memberDenot(prefix, name, true)
1682-
assert(!d1.exists, i"bad allow private $this $name $d1 at ${ctx.phase}")
1683-
}
1680+
if (!d.exists && ctx.mode.is(Mode.Interactive))
1681+
d = memberDenot(prefix, name, true)
16841682
if (!d.exists && ctx.phaseId > FirstPhaseId && lastDenotation.isInstanceOf[SymDenotation])
16851683
// name has changed; try load in earlier phase and make current
16861684
d = loadDenot(name, allowPrivate)(ctx.withPhase(ctx.phaseId - 1)).current
@@ -1689,6 +1687,9 @@ object Types {
16891687
d
16901688
}
16911689

1690+
/** Reload denotation by computing the member with the reference's name as seen
1691+
* from the reference's prefix.
1692+
*/
16921693
def reloadDenot()(implicit ctx: Context) =
16931694
setDenot(loadDenot(name, allowPrivate = !symbol.exists || symbol.is(Private)))
16941695

@@ -1697,7 +1698,7 @@ object Types {
16971698

16981699
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
16991700
val sig = currentSignature
1700-
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig")
1701+
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig") // DEBUG
17011702
if (sig != null)
17021703
d.atSignature(sig, relaxed = !ctx.erasedTypes) match {
17031704
case d1: SingleDenotation => d1
@@ -1891,10 +1892,12 @@ object Types {
18911892
case _ => withPrefix(prefix)
18921893
}
18931894

1895+
/** A reference like this one, but with the given symbol, if it exists */
18941896
final def withSym(sym: Symbol)(implicit ctx: Context): ThisType =
18951897
if ((designator ne sym) && sym.exists) NamedType(prefix, sym).asInstanceOf[ThisType]
18961898
else this
18971899

1900+
/** A reference like this one, but with the given denotation, if it exists */
18981901
final def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
18991902
if (denot.exists) {
19001903
val adapted = withSym(denot.symbol)
@@ -1907,8 +1910,7 @@ object Types {
19071910
else // don't assign NoDenotation, we might need to recover later. Test case is pos/avoid.scala.
19081911
this
19091912

1910-
/** Create a NamedType of the same kind as this type, but with a new prefix.
1911-
*/
1913+
/** A reference like this one, but with the given prefix. */
19121914
final def withPrefix(prefix: Type)(implicit ctx: Context): NamedType = {
19131915
def reload(): NamedType = {
19141916
val allowPrivate = !lastSymbol.exists || lastSymbol.is(Private) && prefix.classSymbol == this.prefix.classSymbol
@@ -1921,7 +1923,8 @@ object Types {
19211923
}
19221924
NamedType(prefix, name, d)
19231925
}
1924-
if (lastDenotation == null) NamedType(prefix, designator)
1926+
if (prefix eq this.prefix) this
1927+
else if (lastDenotation == null) NamedType(prefix, designator)
19251928
else designator match {
19261929
case sym: Symbol =>
19271930
if (infoDependsOnPrefix(sym, prefix)) {

compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ElimErasedValueType extends MiniPhase with InfoTransformer {
8686
val site = root.thisType
8787
val info1 = site.memberInfo(sym1)
8888
val info2 = site.memberInfo(sym2)
89-
def isDefined(sym: Symbol) = sym.lastKnownDenotation.initial.validFor.firstPhaseId <= ctx.phaseId
89+
def isDefined(sym: Symbol) = sym.originDenotation.validFor.firstPhaseId <= ctx.phaseId
9090
if (isDefined(sym1) && isDefined(sym2) && !info1.matchesLoosely(info2))
9191
// The reason for the `isDefined` condition is that we need to exclude mixin forwarders
9292
// from the tests. For instance, in compileStdLib, compiling scala.immutable.SetProxy, line 29:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ object Checking {
244244
locked += tp
245245
try checkInfo(tp.info)
246246
finally locked -= tp
247-
if (pre1 eq pre) tp else tp.withPrefix(pre1)
247+
tp.withPrefix(pre1)
248248
}
249249
else tp
250250
} catch {

tests/pending/pos/t2405.scala

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)