Skip to content

Commit a80a55c

Browse files
committed
Better diagnostic for "failure to disambiguate" errors
1 parent 825f8de commit a80a55c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,15 @@ object Denotations {
310310
}
311311
case tp1: MethodOrPoly =>
312312
tp2 match {
313-
case tp2: MethodOrPoly
314-
if ctx.typeComparer.matchingParams(tp1, tp2) &&
315-
tp1.isImplicit == tp2.isImplicit =>
316-
tp1.derivedLambdaType(
317-
mergeParamNames(tp1, tp2), tp1.paramInfos,
318-
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
313+
case tp2: MethodOrPoly =>
314+
if (tp1.isInstanceOf[PolyType] && tp2.isInstanceOf[MethodType]) tp2
315+
else if (tp2.isInstanceOf[PolyType] && tp1.isInstanceOf[MethodType]) tp1
316+
else if (ctx.typeComparer.matchingParams(tp1, tp2) &&
317+
tp1.isImplicit == tp2.isImplicit)
318+
tp1.derivedLambdaType(
319+
mergeParamNames(tp1, tp2), tp1.paramInfos,
320+
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
321+
else mergeConflict(tp1, tp2)
319322
case _ =>
320323
mergeConflict(tp1, tp2)
321324
}
@@ -553,7 +556,7 @@ object Denotations {
553556
if (sd1.exists)
554557
if (sd2.exists)
555558
if (isDoubleDef(denot1.symbol, denot2.symbol)) doubleDefError(denot1, denot2)
556-
else throw new TypeError(s"failure to disambiguate overloaded reference $this")
559+
else throw new TypeError(i"failure to disambiguate overloaded reference at $this")
557560
else sd1
558561
else sd2
559562
}

0 commit comments

Comments
 (0)