@@ -3922,26 +3922,13 @@ object Types {
3922
3922
case c : ErasedMethodCompanion => c.erasedParams(paramInfos)
3923
3923
case _ => super .erasedParams
3924
3924
3925
- // Mark erased classes as erased parameters as well.
3926
- def markErasedClasses (using Context ): MethodType =
3927
- val isErasedClass = paramInfos.map(_.isErasedClass)
3928
- if isErasedClass.contains(true ) then companion match
3929
- case c : ErasedMethodCompanion =>
3930
- val baseErasedParams = c.erasedParams(paramInfos)
3931
- val erasedParams = baseErasedParams.zipWithConserve(isErasedClass) { (a, b) => a || b }
3932
- if erasedParams == baseErasedParams then this
3933
- else MethodType .companion(
3934
- isContextual = isContextualMethod,
3935
- isImplicit = isImplicitMethod,
3936
- erasedParams = erasedParams
3937
- )(paramNames)(paramInfosExp, resultTypeExp)
3938
- case _ =>
3939
- MethodType .companion(
3940
- isContextual = isContextualMethod,
3941
- isImplicit = isImplicitMethod,
3942
- erasedParams = isErasedClass
3943
- )(paramNames)(paramInfosExp, resultTypeExp)
3944
- else this
3925
+ /** Returns the corresponding companion, but without erased parameters */
3926
+ final def companionWithoutErased = companion match
3927
+ case ErasedImplicitMethodType => ImplicitMethodType
3928
+ case ErasedContextualMethodType => ContextualMethodType
3929
+ case ErasedMethodType => MethodType
3930
+ case actual => actual
3931
+
3945
3932
3946
3933
protected def prefixString : String = companion.prefixString
3947
3934
}
@@ -4038,7 +4025,7 @@ object Types {
4038
4025
tl => tl.integrate(params, resultType))
4039
4026
end fromSymbols
4040
4027
4041
- final def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(using Context ): MethodType =
4028
+ def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(using Context ): MethodType =
4042
4029
checkValid(unique(new CachedMethodType (paramNames)(paramInfosExp, resultTypeExp, self)))
4043
4030
4044
4031
def checkValid (mt : MethodType )(using Context ): mt.type = {
@@ -4062,18 +4049,24 @@ object Types {
4062
4049
else
4063
4050
if (hasErased) ErasedMethodType else MethodType
4064
4051
}
4065
- sealed abstract class ErasedMethodCompanion (prefixString : String )
4066
- extends MethodTypeCompanion (" Erased" + prefixString) {
4052
+ sealed abstract class ErasedMethodCompanion (withoutErased : MethodTypeCompanion )
4053
+ extends MethodTypeCompanion (" Erased" + withoutErased.prefixString) {
4054
+
4055
+ override def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(using Context ): MethodType =
4056
+ val mt = super .apply(paramNames)(paramInfosExp, resultTypeExp)
4057
+ // assert(erasedParams(mt.paramInfos).contains(true), s"$mt must contain an erased parameter")
4058
+ if erasedParams(mt.paramInfos).contains(true ) then mt
4059
+ else withoutErased(paramNames)(paramInfosExp, resultTypeExp)
4067
4060
4068
4061
def erasedParams (paramsInfo : List [Type ])(using Context ) =
4069
- paramsInfo.map(_ .hasAnnotation(defn.ErasedParamAnnot ))
4062
+ paramsInfo.map(p => p .hasAnnotation(defn.ErasedParamAnnot ) || p.isErasedClass )
4070
4063
}
4071
4064
4072
- object ErasedMethodType extends ErasedMethodCompanion (" MethodType" )
4065
+ object ErasedMethodType extends ErasedMethodCompanion (MethodType )
4073
4066
object ContextualMethodType extends MethodTypeCompanion (" ContextualMethodType" )
4074
- object ErasedContextualMethodType extends ErasedMethodCompanion (" ContextualMethodType" )
4067
+ object ErasedContextualMethodType extends ErasedMethodCompanion (ContextualMethodType )
4075
4068
object ImplicitMethodType extends MethodTypeCompanion (" ImplicitMethodType" )
4076
- object ErasedImplicitMethodType extends ErasedMethodCompanion (" ImplicitMethodType" )
4069
+ object ErasedImplicitMethodType extends ErasedMethodCompanion (ImplicitMethodType )
4077
4070
4078
4071
/** A ternary extractor for MethodType */
4079
4072
object MethodTpe {
0 commit comments