Skip to content

Commit 9db13da

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 704e8df commit 9db13da

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
@@ -443,10 +443,17 @@ trait Applications extends Compatibility {
443443
/** The function's type after widening and instantiating polytypes
444444
* with TypeParamRefs in constraint set
445445
*/
446-
@threadUnsafe lazy val methType: Type = liftedFunType.widen match {
447-
case funType: MethodType => funType
448-
case funType: PolyType => instantiateWithTypeVars(funType)
449-
case tp => tp //was: funType
446+
@threadUnsafe lazy val methType: Type = {
447+
def rec(t: Type): Type = {
448+
t.widen match{
449+
case funType: MethodType => funType
450+
case funType: PolyType =>
451+
rec(instantiateWithTypeVars(funType))
452+
case tp => tp
453+
}
454+
}
455+
456+
rec(liftedFunType)
450457
}
451458

452459
@threadUnsafe lazy val liftedFunType: Type =
@@ -1143,8 +1150,6 @@ trait Applications extends Compatibility {
11431150
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
11441151
record("typedTypeApply")
11451152
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
1146-
case _: TypeApply if !ctx.isAfterTyper =>
1147-
errorTree(tree, em"illegal repeated type application")
11481153
case typedFn =>
11491154
typedFn.tpe.widen match {
11501155
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)