Skip to content

Commit 3568757

Browse files
committed
Fix check not to run after typer
After typer we can get two consecutive type argument sections. If the first section consists of named parameters that leave out some parameter bindings they are supplied in the second section. I considered merging the two type parameter sections, but that would complicate too many other things. The current scheme is still unambiguous if we consider types. I.e. two consecutive argument sections match a single formal parameter section if the first section is named and the length of both argument sections together matches the number of formal parameters. Also, fix tests.
1 parent d10a7b1 commit 3568757

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
881881
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
882882
case ExtMethodApply(app) =>
883883
app
884-
case _: TypeApply =>
884+
case _: TypeApply if !ctx.isAfterTyper =>
885885
errorTree(tree, "illegal repeated type application")
886886
case typedFn =>
887887
typedFn.tpe.widen match {

tests/neg/namedTypeParams.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ object Test {
1212
def f[X, Y](x: X, y: Y): Int = ???
1313

1414
f[X = Int, String](1, "") // error // error
15-
f[X = Int][X = Int][Y = String](1, "") // error
15+
f[X = Int][X = Int][Y = String](1, "") // error: illegal repeated type application
16+
17+
f[X = Int][Y = String](1, "") // error: illegal repeated type application
18+
f[X = Int][String](1, "") // error: illegal repeated type application
19+
20+
f[Y = String][X = Int](1, "") // error: illegal repeated type application
21+
f[Y = String][Int](1, "") // error: illegal repeated type application
1622
}

tests/pos/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, Z]: C[X, Y] = new C[X, Y]
5+
f[Int, Boolean, Any][String](1, true, "") // OK
6+
f[X = Int](1, true, "") // OK, Y and Z are inferred
7+
f[Z = Any, X = Int](1, true, "") // OK
8+
}

tests/pos/namedTypeParams.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ object Test {
77
f[X = Int](1, "")
88
f[Y = String](1, "")
99

10-
f[X = Int][Y = String](1, "")
11-
f[X = Int][String](1, "")
1210

13-
f[Y = String][X = Int](1, "")
14-
f[Y = String][Int](1, "")
1511
}

0 commit comments

Comments
 (0)