Skip to content

Commit e0f115a

Browse files
committed
Fix assumptions in Applications.scala
A check is removed that forbids interweaved 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 667e17f commit e0f115a

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
@@ -409,10 +409,17 @@ trait Applications extends Compatibility {
409409
/** The function's type after widening and instantiating polytypes
410410
* with TypeParamRefs in constraint set
411411
*/
412-
@threadUnsafe lazy val methType: Type = liftedFunType.widen match {
413-
case funType: MethodType => funType
414-
case funType: PolyType => instantiateWithTypeVars(funType)
415-
case tp => tp //was: funType
412+
@threadUnsafe lazy val methType: Type = {
413+
def rec(t: Type): Type = {
414+
t.widen match{
415+
case funType: MethodType => funType
416+
case funType: PolyType =>
417+
rec(instantiateWithTypeVars(funType))
418+
case tp => tp
419+
}
420+
}
421+
422+
rec(liftedFunType)
416423
}
417424

418425
@threadUnsafe lazy val liftedFunType: Type =
@@ -1077,8 +1084,6 @@ trait Applications extends Compatibility {
10771084
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
10781085
record("typedTypeApply")
10791086
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
1080-
case _: TypeApply if !ctx.isAfterTyper =>
1081-
errorTree(tree, "illegal repeated type application")
10821087
case typedFn =>
10831088
typedFn.tpe.widen match {
10841089
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)