Skip to content

Commit 5000f5f

Browse files
committed
Fixed #143
The problem was that TermRefWithSignatures did not take shadowed names into account when reconstituting themselves under a new prefix.
1 parent 9e1759f commit 5000f5f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,7 @@ object Types {
11661166
TermRef.withSig(prefix, name.asTermName, sig)
11671167

11681168
protected def loadDenot(implicit ctx: Context): Denotation = {
1169-
val d =
1170-
if (name.isInheritedName) prefix.nonPrivateMember(name.revertInherited)
1171-
else prefix.member(name)
1169+
val d = asMemberOf(prefix)
11721170
if (d.exists || ctx.phaseId == FirstPhaseId || !lastDenotation.isInstanceOf[SymDenotation])
11731171
d
11741172
else { // name has changed; try load in earlier phase and make current
@@ -1178,6 +1176,10 @@ object Types {
11781176
}
11791177
}
11801178

1179+
protected def asMemberOf(prefix: Type)(implicit ctx: Context) =
1180+
if (name.isInheritedName) prefix.nonPrivateMember(name.revertInherited)
1181+
else prefix.member(name)
1182+
11811183
def symbol(implicit ctx: Context): Symbol = {
11821184
val now = ctx.period
11831185
if (checkedPeriod == now ||
@@ -1289,7 +1291,7 @@ object Types {
12891291
sig != Signature.OverloadedSignature &&
12901292
symbol.exists) {
12911293
val ownSym = symbol
1292-
TermRef(prefix, name).withDenot(prefix.member(name).disambiguate(_ eq ownSym))
1294+
TermRef(prefix, name).withDenot(asMemberOf(prefix).disambiguate(_ eq ownSym))
12931295
}
12941296
else TermRef.withSig(prefix, name, sig)
12951297
}

tests/pending/pos/i143.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dotty.tools.dotc
2+
package transform
3+
4+
import dotty.tools.dotc.core.Denotations._
5+
import dotty.tools.dotc.core.Symbols._
6+
import dotty.tools.dotc.core.Contexts._
7+
8+
class TC5 extends AnyVal {
9+
implicit val ctx: Context = ???
10+
11+
def candidates(mbr: SingleDenotation): Boolean = {
12+
mbr.symbol.denot(ctx).exists
13+
}
14+
}

0 commit comments

Comments
 (0)