Skip to content

Commit f1c5855

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 897deaf commit f1c5855

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,17 @@ trait Applications extends Compatibility {
444444
/** The function's type after widening and instantiating polytypes
445445
* with TypeParamRefs in constraint set
446446
*/
447-
@threadUnsafe lazy val methType: Type = liftedFunType.widen match {
448-
case funType: MethodType => funType
449-
case funType: PolyType => instantiateWithTypeVars(funType)
450-
case tp => tp //was: funType
447+
@threadUnsafe lazy val methType: Type = {
448+
def rec(t: Type): Type = {
449+
t.widen match{
450+
case funType: MethodType => funType
451+
case funType: PolyType =>
452+
rec(instantiateWithTypeVars(funType))
453+
case tp => tp
454+
}
455+
}
456+
457+
rec(liftedFunType)
451458
}
452459

453460
@threadUnsafe lazy val liftedFunType: Type =
@@ -1144,8 +1151,6 @@ trait Applications extends Compatibility {
11441151
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
11451152
record("typedTypeApply")
11461153
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
1147-
case _: TypeApply if !ctx.isAfterTyper =>
1148-
errorTree(tree, em"illegal repeated type application")
11491154
case typedFn =>
11501155
typedFn.tpe.widen match {
11511156
case pt: PolyType =>

tests/neg/namedTypeParams.scala

Lines changed: 2 additions & 0 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+
/* Conflicts with Clause Interweaving, stems from named type parameters assuming one type clause
2021
f[X = Int][X = Int][Y = String](1, "") // error: illegal repeated type application
2122
2223
f[X = Int][Y = String](1, "") // error: illegal repeated type application
2324
f[X = Int][String](1, "") // error: illegal repeated type application
2425
2526
f[Y = String][X = Int](1, "") // error: illegal repeated type application
2627
f[Y = String][Int](1, "") // error: illegal repeated type application
28+
*/
2729
}

0 commit comments

Comments
 (0)