Skip to content

Commit 3edf285

Browse files
committed
Rename isWeakRef -> isTightPrefix
isWeakRef was confusing because this has nothing to do with weak pointers.
1 parent 6780dbd commit 3edf285

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ object Types {
126126
false
127127
}
128128

129-
/** Same as `isRef`, but follows more types: all type proxies as well as and- and or-types */
130-
private[Types] def isWeakRef(sym: Symbol)(implicit ctx: Context): Boolean = stripTypeVar match {
131-
case tp: NamedType => tp.info.isWeakRef(sym)
129+
/** Does this type refer exactly to class symbol `sym`, instead of to a subclass of `sym`?
130+
* Implemented like `isRef`, but follows more types: all type proxies as well as and- and or-types
131+
*/
132+
private[Types] def isTightPrefix(sym: Symbol)(implicit ctx: Context): Boolean = stripTypeVar match {
133+
case tp: NamedType => tp.info.isTightPrefix(sym)
132134
case tp: ClassInfo => tp.cls eq sym
133135
case tp: Types.ThisType => tp.cls eq sym
134-
case tp: TypeProxy => tp.underlying.isWeakRef(sym)
135-
case tp: AndType => tp.tp1.isWeakRef(sym) && tp.tp2.isWeakRef(sym)
136-
case tp: OrType => tp.tp1.isWeakRef(sym) || tp.tp2.isWeakRef(sym)
136+
case tp: TypeProxy => tp.underlying.isTightPrefix(sym)
137+
case tp: AndType => tp.tp1.isTightPrefix(sym) && tp.tp2.isTightPrefix(sym)
138+
case tp: OrType => tp.tp1.isTightPrefix(sym) || tp.tp2.isTightPrefix(sym)
137139
case _ => false
138140
}
139141

@@ -1229,7 +1231,7 @@ object Types {
12291231
case d: SymDenotation =>
12301232
if (this.isInstanceOf[WithFixedSym]) d.current
12311233
else if (d.validFor.runId == ctx.runId || ctx.stillValid(d))
1232-
if (prefix.isWeakRef(d.owner) || d.isConstructor) d.current
1234+
if (prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
12331235
else recomputeMember(d) // symbol could have been overridden, recompute membership
12341236
else {
12351237
val newd = loadDenot

0 commit comments

Comments
 (0)