@@ -1444,7 +1444,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1444
1444
NoType
1445
1445
}
1446
1446
1447
- val calleeIsErased = calleeType.widen match {
1447
+ lazy val calleeIsErased = calleeType.widen match {
1448
1448
case mt : MethodType if mt.isErasedMethod =>
1449
1449
val companion = mt.companion.asInstanceOf [ErasedMethodCompanion ]
1450
1450
params.map(p => companion.isErased(paramIndex(p.name)))
@@ -1466,7 +1466,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1466
1466
1467
1467
/** Returns the type and whether the parameter is erased */
1468
1468
def protoFormal (i : Int ): (Type , Boolean ) =
1469
- if (protoFormals.length == params.length) (protoFormals(i), calleeIsErased(i) || isDefinedErased(i))
1469
+ if (protoFormals.length == params.length) (protoFormals(i), isDefinedErased(i))
1470
1470
else (errorType(WrongNumberOfParameters (protoFormals.length), tree.srcPos), isDefinedErased(i))
1471
1471
1472
1472
/** Is `formal` a product type which is elementwise compatible with `params`? */
@@ -1504,21 +1504,23 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1504
1504
val inferredParams : List [untpd.ValDef ] =
1505
1505
for ((param, i) <- params.zipWithIndex) yield
1506
1506
val (formal, isErased) = protoFormal(i)
1507
- val param0 =
1508
- if (! param.tpt.isEmpty) param
1507
+ val ( param0, isErased1) =
1508
+ if (! param.tpt.isEmpty) ( param, false )
1509
1509
else
1510
1510
val knownFormal = isFullyDefined(formal, ForceDegree .failBottom)
1511
- val paramType =
1512
- if knownFormal then formal
1513
- else inferredFromTarget(param, formal, calleeType, paramIndex)
1514
- .orElse(errorType(AnonymousFunctionMissingParamType (param, tree, formal), param.srcPos))
1511
+ val (paramType, isErased1) =
1512
+ if knownFormal then (formal, false )
1513
+ else
1514
+ val tpe = inferredFromTarget(param, formal, calleeType, paramIndex)
1515
+ .orElse(errorType(AnonymousFunctionMissingParamType (param, tree, formal), param.srcPos))
1516
+ (tpe, calleeIsErased(i))
1515
1517
val paramTpt = untpd.TypedSplice (
1516
1518
(if knownFormal then InferredTypeTree () else untpd.TypeTree ())
1517
1519
.withType(paramType.translateFromRepeated(toArray = false ))
1518
1520
.withSpan(param.span.endPos)
1519
1521
)
1520
- cpy.ValDef (param)(tpt = paramTpt)
1521
- if isErased then param0.withAddedFlags(Flags .Erased ) else param0
1522
+ ( cpy.ValDef (param)(tpt = paramTpt), isErased1 )
1523
+ if isErased || isErased1 then param0.withAddedFlags(Flags .Erased ) else param0
1522
1524
desugared = desugar.makeClosure(inferredParams, fnBody, resultTpt, isContextual, tree.span)
1523
1525
1524
1526
typed(desugared, pt)
0 commit comments