Skip to content

Commit 7bbc222

Browse files
committed
Fix problem of overloading resolution when receiver is not stable.
1 parent 1571c2b commit 7bbc222

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,10 +1500,7 @@ object SymDenotations {
15001500
val decls1 = newScope
15011501
for (tparam <- tparams) decls1.enter(decls.lookup(tparam.name))
15021502
for (sym <- decls) if (!typeParams.contains(sym)) decls1.enter(sym)
1503-
val ci = classInfo
1504-
// dotty deviation; overloading resolution on next line fails if prefix `ci` is not a value.
1505-
// See test pending/pos/overloaddefault.scala
1506-
info = ci.derivedClassInfo(decls = decls1)
1503+
info = classInfo.derivedClassInfo(decls = decls1)
15071504
myTypeParams = null
15081505
}
15091506

src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
246246

247247
// Drop accessors that are not retained from class scope
248248
if (dropped.nonEmpty) {
249-
val clsInfo = cls.classInfo // TODO investigate: expand clsInfo to cls.info => dotty type error
249+
val clsInfo = cls.classInfo
250250
cls.copy(
251251
info = clsInfo.derivedClassInfo(
252252
decls = clsInfo.decls.filteredScope(!dropped.contains(_))))

src/dotty/tools/dotc/transform/RestoreScopes.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ class RestoreScopes extends MiniPhaseTransform with IdentityDenotTransformer { t
4848
}
4949

5050
pkg.enter(cls)
51-
val cinfo = cls.classInfo
5251
tree.symbol.copySymDenotation(
53-
info = cinfo.derivedClassInfo( // Dotty deviation: Cannot expand cinfo inline without a type error
52+
info = cls.classInfo.derivedClassInfo(
5453
decls = restoredDecls: Scope)).installAfter(thisTransform)
5554
tree
5655
}

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,13 @@ trait Applications extends Compatibility { self: Typer =>
262262
val receiver: Tree = methPart(normalizedFun) match {
263263
case Select(receiver, _) => receiver
264264
case mr => mr.tpe.normalizedPrefix match {
265-
case mr: TermRef => ref(mr)
266-
case _ => EmptyTree
265+
case mr: TermRef =>
266+
ref(mr)
267+
case mr: TypeRef if this.isInstanceOf[TestApplication[_]] =>
268+
// In this case it is safe to skolemize now; we will produce a stable prefix for the actual call.
269+
ref(mr.narrow)
270+
case _ =>
271+
EmptyTree
267272
}
268273
}
269274
val getterPrefix =

0 commit comments

Comments
 (0)