Skip to content

Commit 8971f1f

Browse files
committed
Get rid of referenced to WithFixedSym
- simplify Substituters - use sym.isOverridable as a test instead of checking whether the reference is a WithFixedSym.
1 parent 2cee5a7 commit 8971f1f

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ object Trees {
8585
* which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer,
8686
* where we overwrite with a simplified version of the type itself.
8787
*/
88-
private[dotc] def overwriteType(tpe: T) = {
89-
if (this.isInstanceOf[Template[_]]) assert(tpe.isInstanceOf[WithFixedSym], s"$this <--- $tpe")
88+
private[dotc] def overwriteType(tpe: T) =
9089
myTpe = tpe
91-
}
9290

9391
/** The type of the tree. In case of an untyped tree,
9492
* an UnAssignedTypeException is thrown. (Overridden by empty trees)

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ trait Substituters { this: Context =>
130130
var ts = to
131131
while (fs.nonEmpty) {
132132
if (fs.head eq sym)
133-
return tp match {
134-
case tp: WithFixedSym => NamedType.withFixedSym(tp.prefix, ts.head)
135-
case _ => substSym(tp.prefix, from, to, theMap) select ts.head
136-
}
133+
return substSym(tp.prefix, from, to, theMap) select ts.head
137134
fs = fs.tail
138135
ts = ts.tail
139136
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,10 @@ object SymDenotations {
457457
validFor.runId == ctx.runId || ctx.stillValid(this)
458458

459459
final def isReferencedSymbolically(implicit ctx: Context) =
460-
(this is NonMember) || isTerm && ctx.phase.symbolicRefs
460+
is(NonMember) || isTerm && ctx.phase.symbolicRefs
461+
462+
final def isOverridable(implicit ctx: Context) =
463+
!(isReferencedSymbolically || is(Private) || isConstructor || maybeOwner.isTerm)
461464

462465
/** Is this symbol the root class or its companion object? */
463466
final def isRoot: Boolean =

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
189189
tp1.symbol.companionModule
190190
else
191191
tp1.symbol
192-
if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol))
192+
val sym2 = tp2.symbol
193+
if ((sym1 ne NoSymbol) && (sym1 eq sym2))
193194
ctx.erasedTypes ||
194195
sym1.isStaticOwner ||
195196
isSubType(tp1.prefix, tp2.prefix) ||
@@ -198,8 +199,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
198199
( (tp1.name eq tp2.name)
199200
&& isSubType(tp1.prefix, tp2.prefix)
200201
&& tp1.signature == tp2.signature
201-
&& !tp1.isInstanceOf[WithFixedSym]
202-
&& !tp2.isInstanceOf[WithFixedSym]
202+
&& sym1.isOverridable
203+
&& sym2.isOverridable
203204
) ||
204205
thirdTryNamed(tp1, tp2)
205206
case _ =>

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,12 +1562,6 @@ 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-
15711565
/** A second fallback to recompute the denotation if necessary */
15721566
private def computeDenot(implicit ctx: Context): Denotation = {
15731567
val savedEphemeral = ctx.typerState.ephemeral
@@ -1579,7 +1573,7 @@ object Types {
15791573
if (sym != null && sym.isValidInCurrentRun) denotOfSym(sym) else loadDenot
15801574
case d: SymDenotation =>
15811575
if (d.isValidInCurrentRun)
1582-
if (keepSymbol(d)) d.current
1576+
if (!d.isOverridable || d.exists && prefix.isTightPrefix(d.owner)) d.current
15831577
else recomputeMember(d) // symbol could have been overridden, recompute membership
15841578
else {
15851579
val newd = loadDenot

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ class TreeChecker extends Phase with SymTransformer {
320320
assert(tree.isTerm || !ctx.isAfterTyper, tree.show + " at " + ctx.phase)
321321
val tpe = tree.typeOpt
322322
val sym = tree.symbol
323-
if (!tpe.isInstanceOf[WithFixedSym] &&
324-
sym.exists && !sym.is(Private) &&
323+
if (sym.exists && sym.isOverridable &&
325324
!tree.name.is(OuterSelectName) // outer selects have effectively fixed symbols
326325
) {
327326
val qualTpe = tree.qualifier.typeOpt

0 commit comments

Comments
 (0)