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