Skip to content

Commit 3299f3b

Browse files
committed
Fix #5328: Disallow repeated type application
1 parent fcc35d2 commit 3299f3b

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
@@ -881,6 +881,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
881881
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
882882
case ExtMethodApply(app) =>
883883
app
884+
case typedFn: TypeApply =>
885+
errorTree(tree, "illegal repeated type application")
884886
case typedFn =>
885887
typedFn.tpe.widen match {
886888
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)