@@ -1441,6 +1441,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1441
1441
NoType
1442
1442
}
1443
1443
1444
+ val calleeIsErased = calleeType.widen match {
1445
+ case mt : MethodType if mt.isErasedMethod =>
1446
+ val companion = mt.companion.asInstanceOf [ErasedMethodCompanion ]
1447
+ params.map(p => companion.isErased(paramIndex(p.name)))
1448
+ // companion.isErased
1449
+ case _ => params.map(_ => false )
1450
+ }
1451
+ // println(s"callee type = ${calleeType.widen}")
1452
+
1444
1453
pt match {
1445
1454
case pt : TypeVar
1446
1455
if untpd.isFunctionWithUnknownParamType(tree) && ! calleeType.exists =>
@@ -1453,15 +1462,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1453
1462
1454
1463
val (protoFormals, resultTpt) = decomposeProtoFunction(pt, params.length, tree.srcPos)
1455
1464
1456
- val protoIsErased = pt match {
1457
- case RefinedType (_, _, mt : MethodType ) if mt.isErasedMethod =>
1458
- mt.companion.asInstanceOf [ErasedMethodCompanion ].isErased
1459
- case _ => List .fill(protoFormals.length)(false )
1460
- }
1461
-
1462
1465
/** Returns the type and whether the parameter is erased */
1463
1466
def protoFormal (i : Int ): (Type , Boolean ) =
1464
- if (protoFormals.length == params.length) (protoFormals(i), protoIsErased (i) || isDefinedErased(i))
1467
+ if (protoFormals.length == params.length) (protoFormals(i), calleeIsErased (i) || isDefinedErased(i))
1465
1468
else (errorType(WrongNumberOfParameters (protoFormals.length), tree.srcPos), isDefinedErased(i))
1466
1469
1467
1470
/** Is `formal` a product type which is elementwise compatible with `params`? */
@@ -1500,7 +1503,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1500
1503
for ((param, i) <- params.zipWithIndex) yield
1501
1504
if (! param.tpt.isEmpty) param
1502
1505
else
1503
- val (formal, isProtoErased ) = protoFormal(i)
1506
+ val (formal, isErased ) = protoFormal(i)
1504
1507
val knownFormal = isFullyDefined(formal, ForceDegree .failBottom)
1505
1508
val paramType =
1506
1509
if knownFormal then formal
@@ -1511,8 +1514,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1511
1514
.withType(paramType.translateFromRepeated(toArray = false ))
1512
1515
.withSpan(param.span.endPos)
1513
1516
)
1514
- val isErased = isProtoErased || paramType.hasAnnotation(defn. ErasedParamAnnot )
1515
- cpy.ValDef (param )(tpt = paramTpt)
1517
+ val param1 = if isErased then param.withAddedFlags( Flags . Erased ) else param
1518
+ cpy.ValDef (param1 )(tpt = paramTpt)
1516
1519
desugared = desugar.makeClosure(inferredParams, fnBody, resultTpt, isContextual, tree.span)
1517
1520
1518
1521
typed(desugared, pt)
0 commit comments