Skip to content

Commit 8d6e647

Browse files
oderskynicolasstucki
authored andcommitted
Fix scala#5328: Disallow repeated type application
1 parent cb32a5a commit 8d6e647

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-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
@@ -898,6 +898,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
898898
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
899899
case ExtMethodApply(app) =>
900900
app
901+
case typedFn: TypeApply =>
902+
errorTree(tree, "illegal repeated type application")
901903
case typedFn =>
902904
typedFn.tpe.widen match {
903905
case pt: PolyType =>

tests/neg/i5328.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class C[X, Y] { def apply[Z](x: X, y: Y, z: Z) = (x, y, z) }
2+
3+
object Test {
4+
def f[X, Y]: C[X, Y] = new C[X, Y]
5+
f[Int, Boolean][String](1, true, "") // OK
6+
f[X = Int](1, true, "") // OK, Y and Z are inferred
7+
f[X = Int][String](1, true, "") // error: illegal repeated type application
8+
}

0 commit comments

Comments
 (0)