Skip to content

Commit d7f780c

Browse files
Pretype args of overloaded app with common expected type of alternatives ..
before skipping the parameter list, to disambiguate with subsequent clauses Fixes scala#23011
1 parent ac47299 commit d7f780c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,10 +2447,12 @@ trait Applications extends Compatibility {
24472447
deepPt match
24482448
case pt @ FunProto(_, PolyProto(targs, resType)) =>
24492449
// try to narrow further with snd argument list and following type params
2450+
pretypeArgs(candidates, pt)
24502451
resolveMapped(candidates,
24512452
skipParamClause(pt.typedArgs().tpes, targs.tpes), resType)
24522453
case pt @ FunProto(_, resType: FunOrPolyProto) =>
24532454
// try to narrow further with snd argument list
2455+
pretypeArgs(candidates, pt)
24542456
resolveMapped(candidates,
24552457
skipParamClause(pt.typedArgs().tpes, Nil), resType)
24562458
case _ =>

tests/pos/i23011.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
type X = Double => Unit
3+
def g(x: Double): Unit = ???
4+
def g(x: String): Unit = ???
5+
6+
def f1(x: X) = ???
7+
8+
def f2(x: X, y: Int) = ???
9+
def f2(x: X, y: Boolean) = ???
10+
11+
def f3(x: X)(y: Int) = ???
12+
def f3(x: X)(y: Boolean) = ???
13+
14+
val r1 = f1(g) // ok
15+
val r2 = f2(g, 1) // ok
16+
val r3 = f3(g)(1) // was error: ambiguous overload for g

0 commit comments

Comments
 (0)