Skip to content

Commit 6286c0f

Browse files
committed
Add back type inference for erased parameters in closures
Also stops the type inference from automatically marking parameters as erased.
1 parent 7e03fee commit 6286c0f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,8 @@ object Types {
17101710
else NoType
17111711
case t if defn.isNonRefinedFunction(t) =>
17121712
t
1713+
case t if defn.isErasedFunctionType(t) =>
1714+
t
17131715
case t @ SAMType(_) =>
17141716
t
17151717
case _ =>

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
12381238
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
12391239
if defn.isNonRefinedFunction(parent) && formals.length == defaultArity =>
12401240
(formals, untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef))))
1241+
case RefinedType(parent, nme.apply, mt @ MethodTpe(_, formals, restpe))
1242+
if defn.isErasedFunctionType(parent) && formals.length == defaultArity =>
1243+
(formals, untpd.DependentTypeTree(syms => restpe.substParams(mt, syms.map(_.termRef))))
12411244
case SAMType(mt @ MethodTpe(_, formals, restpe)) =>
12421245
(formals,
12431246
if (mt.isResultDependent)
@@ -1509,8 +1512,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15091512
.withSpan(param.span.endPos)
15101513
)
15111514
val isErased = isProtoErased || paramType.hasAnnotation(defn.ErasedParamAnnot)
1512-
val param1 = if isErased then param.withAddedFlags(Flags.Erased) else param
1513-
cpy.ValDef(param1)(tpt = paramTpt)
1515+
cpy.ValDef(param)(tpt = paramTpt)
15141516
desugared = desugar.makeClosure(inferredParams, fnBody, resultTpt, isContextual, tree.span)
15151517

15161518
typed(desugared, pt)

0 commit comments

Comments
 (0)