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