Skip to content

Commit 2f24223

Browse files
committed
Fix assumptions in Applications.scala
A check is removed that forbids interleaved methods at use-site This however breaks named type parameters, some tests are thus removed methType implicitly assumed there could only be one leading term parameter clause, this has been changed
1 parent c045c5f commit 2f24223

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,17 @@ trait Applications extends Compatibility {
419419
/** The function's type after widening and instantiating polytypes
420420
* with TypeParamRefs in constraint set
421421
*/
422-
@threadUnsafe lazy val methType: Type = liftedFunType.widen match {
423-
case funType: MethodType => funType
424-
case funType: PolyType => instantiateWithTypeVars(funType)
425-
case tp => tp //was: funType
422+
@threadUnsafe lazy val methType: Type = {
423+
def rec(t: Type): Type = {
424+
t.widen match{
425+
case funType: MethodType => funType
426+
case funType: PolyType =>
427+
rec(instantiateWithTypeVars(funType))
428+
case tp => tp
429+
}
430+
}
431+
432+
rec(liftedFunType)
426433
}
427434

428435
@threadUnsafe lazy val liftedFunType: Type =
@@ -1102,8 +1109,6 @@ trait Applications extends Compatibility {
11021109
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
11031110
record("typedTypeApply")
11041111
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
1105-
case _: TypeApply if !ctx.isAfterTyper =>
1106-
errorTree(tree, "illegal repeated type application")
11071112
case typedFn =>
11081113
typedFn.tpe.widen match {
11091114
case pt: PolyType =>

tests/neg/namedTypeParams.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ object Test {
1717
def f[X, Y](x: X, y: Y): Int = ???
1818

1919
f[X = Int, String](1, "") // error // error
20-
f[X = Int][X = Int][Y = String](1, "") // error: illegal repeated type application
20+
/* Conflicts with Clause Interweaving, stems from named type parameters assuming one type clause
21+
f[X = Int][X = Int][Y = String](1, "")
2122
22-
f[X = Int][Y = String](1, "") // error: illegal repeated type application
23-
f[X = Int][String](1, "") // error: illegal repeated type application
23+
f[X = Int][Y = String](1, "")
24+
f[X = Int][String](1, "")
2425
25-
f[Y = String][X = Int](1, "") // error: illegal repeated type application
26-
f[Y = String][Int](1, "") // error: illegal repeated type application
26+
f[Y = String][X = Int](1, "")
27+
f[Y = String][Int](1, "")
28+
*/
2729
}

0 commit comments

Comments
 (0)