Skip to content

Commit 070b889

Browse files
committed
Fixes to handling of overloaded references
- need to adapt denotation if prefix changes in `withPrefix` - need to recover name of reference from the denotation.
1 parent 7bbeb82 commit 070b889

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,11 @@ object Types {
15391539
}
15401540

15411541
final def name(implicit ctx: Context): ThisName = {
1542-
if (myName == null) myName = designator.asInstanceOf[Symbol].name.asInstanceOf[ThisName]
1542+
if (myName == null) {
1543+
val sym = designator.asInstanceOf[Symbol]
1544+
val d = if (sym.exists || lastDenotation == null) sym.denot else lastDenotation
1545+
myName = d.name.asInstanceOf[ThisName]
1546+
}
15431547
myName
15441548
}
15451549

@@ -2022,7 +2026,9 @@ object Types {
20222026

20232027
def withPrefix(prefix: Type)(implicit ctx: Context): NamedType = designator match {
20242028
case designator: TermSymbol @unchecked =>
2025-
TermRef(prefix, designator)
2029+
val core = TermRef(prefix, designator)
2030+
if (isOverloaded && Config.newScheme) core.withDenot(denot.asSeenFrom(prefix))
2031+
else core
20262032
case _ =>
20272033
// If symbol exists, the new signature is the symbol's signature as seen
20282034
// from the new prefix, modulo consistency

0 commit comments

Comments
 (0)