Skip to content

Commit 6ff32d6

Browse files
committed
Fix #3930: Handle multiple type arguments in overloading resolution
The error message for the neg case is a bit weird, (it complains about an ambiguity error), but improving it would require considerable complications, which I don't think are worth it at the present time.
1 parent a09f385 commit 6ff32d6

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
13881388
}
13891389
}
13901390

1391-
case pt @ PolyProto(targs1, pt1) =>
1392-
assert(targs.isEmpty)
1391+
case pt @ PolyProto(targs1, pt1) if targs.isEmpty =>
13931392
val alts1 = alts filter pt.isMatchedBy
13941393
resolveOverloaded(alts1, pt1, targs1)
13951394

tests/neg/i3930.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object A {
2+
def a[F](x: Int) = 0
3+
def a[F](x: String) = 0
4+
}
5+
object Test extends App {
6+
A.a[String][Int](3) == 1 // error: ambiguous
7+
}

tests/run/i3930.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Apply { def apply[A](x: Int) = 1 }
2+
object A {
3+
def a[F] = new Apply
4+
def a[F](x: String) = 0
5+
}
6+
object Test extends App {
7+
assert(A.a[String][Int](3) == 1)
8+
}

0 commit comments

Comments
 (0)