@@ -1770,24 +1770,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1770
1770
if (mt.isParamDependent)
1771
1771
report.error(em " $mt is an illegal function type because it has inter-parameter dependencies " , tree.srcPos)
1772
1772
// Restart typechecking if there are erased classes that we want to mark erased
1773
- if mt.paramErasureStatuses.zip(mt.paramInfos.map(_.isErasedClass)).exists((paramErased, classErased) => classErased && ! paramErased) then
1774
- val newParams = params3.zipWithConserve(mt.paramInfos.map(_.isErasedClass)) { (arg, isErasedClass) =>
1775
- if isErasedClass then arg.withAddedFlags(Erased ) else arg
1776
- }
1777
- return typedDependent(newParams)
1778
- val core =
1779
- if mt.hasErasedParams then TypeTree (defn.PolyFunctionClass .typeRef)
1780
- else
1781
- val resTpt = TypeTree (mt.nonDependentResultApprox).withSpan(body.span)
1782
- val paramTpts = appDef.termParamss.head.map(p => TypeTree (p.tpt.tpe).withSpan(p.tpt.span))
1783
- val funSym = defn.FunctionSymbol (numArgs, isContextual)
1784
- val tycon = TypeTree (funSym.typeRef)
1785
- AppliedTypeTree (tycon, paramTpts :+ resTpt)
1786
- val res = RefinedTypeTree (core, List (appDef), ctx.owner.asClass)
1787
- if isImpure then
1788
- typed(untpd.makeRetaining(untpd.TypedSplice (res), Nil , tpnme.retainsCap), pt)
1773
+ if mt.paramErasureStatuses.lazyZip(mt.paramInfos).exists: (paramErased, info) =>
1774
+ ! paramErased && info.derivesFrom(defn.ErasedClass )
1775
+ then
1776
+ val newParams = params3.zipWithConserve(mt.paramInfos): (param, info) =>
1777
+ if info.derivesFrom(defn.ErasedClass ) then param.withAddedFlags(Erased ) else param
1778
+ typedDependent(newParams)
1789
1779
else
1790
- res
1780
+ val core =
1781
+ if mt.hasErasedParams then TypeTree (defn.PolyFunctionClass .typeRef)
1782
+ else
1783
+ val resTpt = TypeTree (mt.nonDependentResultApprox).withSpan(body.span)
1784
+ val paramTpts = appDef.termParamss.head.map(p => TypeTree (p.tpt.tpe).withSpan(p.tpt.span))
1785
+ val funSym = defn.FunctionSymbol (numArgs, isContextual)
1786
+ val tycon = TypeTree (funSym.typeRef)
1787
+ AppliedTypeTree (tycon, paramTpts :+ resTpt)
1788
+ val res = RefinedTypeTree (core, List (appDef), ctx.owner.asClass)
1789
+ if isImpure then
1790
+ typed(untpd.makeRetaining(untpd.TypedSplice (res), Nil , tpnme.retainsCap), pt)
1791
+ else
1792
+ res
1791
1793
end typedDependent
1792
1794
1793
1795
args match {
@@ -1802,7 +1804,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1802
1804
val result = typed(cpy.AppliedTypeTree (tree)(untpd.TypeTree (funSym.typeRef), args :+ body), pt)
1803
1805
// if there are any erased classes, we need to re-do the typecheck.
1804
1806
result match
1805
- case r : AppliedTypeTree if r.args.exists(_.tpe.isErasedClass ) =>
1807
+ case r : AppliedTypeTree if r.args.init. exists(_.tpe.derivesFrom(defn. ErasedClass ) ) =>
1806
1808
typedFunctionType(desugar.makeFunctionWithValDefs(tree, pt), pt)
1807
1809
case _ => result
1808
1810
}
@@ -2947,6 +2949,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2947
2949
completeAnnotations(vdef, sym)
2948
2950
if sym.is(Implicit ) then checkImplicitConversionDefOK(sym)
2949
2951
if sym.is(Module ) then checkNoModuleClash(sym)
2952
+ else if sym.info.derivesFrom(defn.ErasedClass ) then
2953
+ sym.setFlag(Erased )
2950
2954
val tpt1 = checkSimpleKinded(typedType(tpt))
2951
2955
val rhs1 = vdef.rhs match
2952
2956
case rhs @ Ident (nme.WILDCARD ) =>
@@ -3071,16 +3075,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3071
3075
}
3072
3076
3073
3077
/** (1) Check that the signature of the class member does not return a repeated parameter type
3074
- * (2) If info is an erased class, set erased flag of member
3075
- * (3) Check that erased classes are not parameters of polymorphic functions.
3076
- * (4) Make sure the definition's symbol is `sym`.
3077
- * (5) Set the `defTree` of `sym` to be `mdef`.
3078
+ * (2) Make sure the definition's symbol is `sym`.
3079
+ * (3) Set the `defTree` of `sym` to be `mdef`.
3078
3080
*/
3079
3081
private def postProcessInfo (mdef : MemberDef , sym : Symbol )(using Context ): MemberDef =
3080
3082
if (! sym.isOneOf(Synthetic | InlineProxy | Param ) && sym.info.finalResultType.isRepeatedParam)
3081
3083
report.error(em " Cannot return repeated parameter type ${sym.info.finalResultType}" , sym.srcPos)
3082
- if ! sym.is(Module ) && ! sym.isConstructor && sym.info.finalResultType.isErasedClass then
3083
- sym.setFlag(Erased )
3084
3084
mdef.ensureHasSym(sym)
3085
3085
mdef.setDefTree
3086
3086
0 commit comments