Skip to content

Commit c3f43f9

Browse files
committed
Polishings
1 parent 0c87b7b commit c3f43f9

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
@@ -1437,9 +1437,10 @@ object SymDenotations {
14371437
if (classParents.isEmpty && !emptyParentsExpected)
14381438
onBehalf.signalProvisional()
14391439
val builder = new BaseDataBuilder
1440-
for (p <- classParents)
1440+
for (p <- classParents) {
1441+
assert(p.typeSymbol.isClass, s"$this has non-class parent: $p")
14411442
builder.addAll(p.typeSymbol.asClass.baseClasses)
1442-
1443+
}
14431444
(classSymbol :: builder.baseClasses, builder.baseClassSet)
14441445
}
14451446

@@ -1851,20 +1852,18 @@ object SymDenotations {
18511852
}
18521853
}
18531854

1854-
class NoDenotation(sym: Symbol, name: Name, override val exists: Boolean)
1855-
extends SymDenotation(sym, NoSymbol, name, Permanent, NoType) {
1855+
@sharable object NoDenotation
1856+
extends SymDenotation(NoSymbol, NoSymbol, "<none>".toTermName, Permanent, NoType) {
18561857
override def isType = false
1857-
override def isTerm = exists
1858+
override def isTerm = false
1859+
override def exists = false
18581860
override def owner: Symbol = throw new AssertionError("NoDenotation.owner")
18591861
override def computeAsSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = this
18601862
override def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation = this
1861-
sym.denot = this
1863+
NoSymbol.denot = this
18621864
validFor = Period.allInRun(NoRunId)
18631865
}
18641866

1865-
@sharable val NoDenotation: NoDenotation =
1866-
new NoDenotation(NoSymbol, "<none>".toTermName, exists = false)
1867-
18681867
// ---- Completion --------------------------------------------------------
18691868

18701869
/** 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
@@ -451,9 +451,10 @@ object Symbols {
451451
final def isValidInCurrentRun(implicit ctx: Context): Boolean =
452452
(lastDenot.validFor.runId == ctx.runId || ctx.stillValid(lastDenot)) &&
453453
(lastDenot.symbol eq this)
454-
// the last condition is needed because overwritten package members keep
455-
// denotations pointing to the new symbol, so the validity periods check out OK.
456-
// But once a package member is overridden it is not longerr valid.
454+
// the last condition is needed because under option -Yupdate-stale overwritten
455+
// package members keep denotations pointing to the new symbol, so the validity
456+
// periods check out OK. But once a package member is overridden it is not longer
457+
// valid. If the option would be removed, the check would be no longer needed.
457458

458459
final def isTerm(implicit ctx: Context): Boolean =
459460
(if (defRunId == ctx.runId) lastDenot else denot).isTerm
@@ -471,14 +472,6 @@ object Symbols {
471472
final def isClass: Boolean = isInstanceOf[ClassSymbol]
472473
final def asClass: ClassSymbol = asInstanceOf[ClassSymbol]
473474

474-
/** Test whether symbol is referenced symbolically. This
475-
* conservatively returns `false` if symbol does not yet have a denotation
476-
*/
477-
final def isReferencedSymbolically(implicit ctx: Context) = {
478-
val d = lastDenot
479-
d != null && (d.is(NonMember) || ctx.phase.symbolicRefs)
480-
}
481-
482475
/** Test whether symbol is private. This
483476
* conservatively returns `false` if symbol does not yet have a denotation, or denotation
484477
* 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
@@ -1686,10 +1686,8 @@ object Types {
16861686

16871687
private def loadDenot(name: Name, allowPrivate: Boolean)(implicit ctx: Context): Denotation = {
16881688
var d = memberDenot(prefix, name, allowPrivate)
1689-
if (!d.exists) {
1690-
val d1 = memberDenot(prefix, name, true)
1691-
assert(!d1.exists, i"bad allow private $this $name $d1 at ${ctx.phase}")
1692-
}
1689+
if (!d.exists && ctx.mode.is(Mode.Interactive))
1690+
d = memberDenot(prefix, name, true)
16931691
if (!d.exists && ctx.phaseId > FirstPhaseId && lastDenotation.isInstanceOf[SymDenotation])
16941692
// name has changed; try load in earlier phase and make current
16951693
d = loadDenot(name, allowPrivate)(ctx.withPhase(ctx.phaseId - 1)).current
@@ -1698,6 +1696,9 @@ object Types {
16981696
d
16991697
}
17001698

1699+
/** Reload denotation by computing the member with the reference's name as seen
1700+
* from the reference's prefix.
1701+
*/
17011702
def reloadDenot()(implicit ctx: Context) =
17021703
setDenot(loadDenot(name, allowPrivate = !symbol.exists || symbol.is(Private)))
17031704

@@ -1706,7 +1707,7 @@ object Types {
17061707

17071708
private def disambiguate(d: Denotation)(implicit ctx: Context): Denotation = {
17081709
val sig = currentSignature
1709-
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig")
1710+
//if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig") // DEBUG
17101711
if (sig != null)
17111712
d.atSignature(sig, relaxed = !ctx.erasedTypes) match {
17121713
case d1: SingleDenotation => d1
@@ -1900,10 +1901,12 @@ object Types {
19001901
case _ => withPrefix(prefix)
19011902
}
19021903

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

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

1919-
/** Create a NamedType of the same kind as this type, but with a new prefix.
1920-
*/
1922+
/** A reference like this one, but with the given prefix. */
19211923
final def withPrefix(prefix: Type)(implicit ctx: Context): NamedType = {
19221924
def reload(): NamedType = {
19231925
val allowPrivate = !lastSymbol.exists || lastSymbol.is(Private) && prefix.classSymbol == this.prefix.classSymbol
@@ -1930,7 +1932,8 @@ object Types {
19301932
}
19311933
NamedType(prefix, name, d)
19321934
}
1933-
if (lastDenotation == null) NamedType(prefix, designator)
1935+
if (prefix eq this.prefix) this
1936+
else if (lastDenotation == null) NamedType(prefix, designator)
19341937
else designator match {
19351938
case sym: Symbol =>
19361939
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)