@@ -427,7 +427,7 @@ object Types {
427
427
def isContextualMethod : Boolean = false
428
428
429
429
/** Is this a MethodType for which the parameters will not be used? */
430
- def hasErasedParams : Boolean = false
430
+ def hasErasedParams ( using Context ) : Boolean = false
431
431
432
432
/** Is this a match type or a higher-kinded abstraction of one?
433
433
*/
@@ -1182,7 +1182,8 @@ object Types {
1182
1182
1183
1183
/** Remove all AnnotatedTypes wrapping this type.
1184
1184
*/
1185
- def stripAnnots (using Context ): Type = this
1185
+ def stripAnnots (keep : Annotation => Context ?=> Boolean )(using Context ): Type = this
1186
+ final def stripAnnots (using Context ): Type = stripAnnots(_ => false )
1186
1187
1187
1188
/** Strip TypeVars and Annotation and CapturingType wrappers */
1188
1189
def stripped (using Context ): Type = this
@@ -3913,26 +3914,14 @@ object Types {
3913
3914
def companion : MethodTypeCompanion
3914
3915
3915
3916
final override def isImplicitMethod : Boolean =
3916
- companion.eq(ImplicitMethodType ) ||
3917
- companion.eq(ErasedImplicitMethodType ) ||
3918
- isContextualMethod
3919
- final override def hasErasedParams : Boolean =
3920
- companion.isInstanceOf [ErasedMethodCompanion ]
3917
+ companion.eq(ImplicitMethodType ) || isContextualMethod
3918
+ final override def hasErasedParams (using Context ): Boolean =
3919
+ erasedParams.contains(true )
3921
3920
final override def isContextualMethod : Boolean =
3922
- companion.eq(ContextualMethodType ) ||
3923
- companion.eq(ErasedContextualMethodType )
3924
-
3925
- override def erasedParams (using Context ): List [Boolean ] = companion match
3926
- case c : ErasedMethodCompanion => c.erasedParams(paramInfos)
3927
- case _ => super .erasedParams
3928
-
3929
- /** Returns the corresponding companion, but without erased parameters */
3930
- final def companionWithoutErased = companion match
3931
- case ErasedImplicitMethodType => ImplicitMethodType
3932
- case ErasedContextualMethodType => ContextualMethodType
3933
- case ErasedMethodType => MethodType
3934
- case actual => actual
3921
+ companion.eq(ContextualMethodType )
3935
3922
3923
+ override def erasedParams (using Context ): List [Boolean ] =
3924
+ paramInfos.map(p => p.hasAnnotation(defn.ErasedParamAnnot ) || p.isErasedClass)
3936
3925
3937
3926
protected def prefixString : String = companion.prefixString
3938
3927
}
@@ -4046,31 +4035,13 @@ object Types {
4046
4035
object MethodType extends MethodTypeCompanion (" MethodType" ) {
4047
4036
def companion (isContextual : Boolean = false , isImplicit : Boolean = false , erasedParams : List [Boolean ] = Nil ): MethodTypeCompanion =
4048
4037
val hasErased = erasedParams.contains(true )
4049
- if (isContextual)
4050
- if (hasErased) ErasedContextualMethodType else ContextualMethodType
4051
- else if (isImplicit)
4052
- if (hasErased) ErasedImplicitMethodType else ImplicitMethodType
4053
- else
4054
- if (hasErased) ErasedMethodType else MethodType
4055
- }
4056
- sealed abstract class ErasedMethodCompanion (withoutErased : MethodTypeCompanion )
4057
- extends MethodTypeCompanion (" Erased" + withoutErased.prefixString) {
4058
-
4059
- override def apply (paramNames : List [TermName ])(paramInfosExp : MethodType => List [Type ], resultTypeExp : MethodType => Type )(using Context ): MethodType =
4060
- val mt = super .apply(paramNames)(paramInfosExp, resultTypeExp)
4061
- // assert(erasedParams(mt.paramInfos).contains(true), s"$mt must contain an erased parameter")
4062
- if erasedParams(mt.paramInfos).contains(true ) then mt
4063
- else withoutErased(paramNames)(paramInfosExp, resultTypeExp)
4064
-
4065
- def erasedParams (paramsInfo : List [Type ])(using Context ) =
4066
- paramsInfo.map(p => p.hasAnnotation(defn.ErasedParamAnnot ) || p.isErasedClass)
4038
+ if (isContextual) ContextualMethodType
4039
+ else if (isImplicit) ImplicitMethodType
4040
+ else MethodType
4067
4041
}
4068
4042
4069
- object ErasedMethodType extends ErasedMethodCompanion (MethodType )
4070
4043
object ContextualMethodType extends MethodTypeCompanion (" ContextualMethodType" )
4071
- object ErasedContextualMethodType extends ErasedMethodCompanion (ContextualMethodType )
4072
4044
object ImplicitMethodType extends MethodTypeCompanion (" ImplicitMethodType" )
4073
- object ErasedImplicitMethodType extends ErasedMethodCompanion (ImplicitMethodType )
4074
4045
4075
4046
/** A ternary extractor for MethodType */
4076
4047
object MethodTpe {
@@ -5285,7 +5256,10 @@ object Types {
5285
5256
override def stripTypeVar (using Context ): Type =
5286
5257
derivedAnnotatedType(parent.stripTypeVar, annot)
5287
5258
5288
- override def stripAnnots (using Context ): Type = parent.stripAnnots
5259
+ override def stripAnnots (keep : Annotation => (Context ) ?=> Boolean )(using Context ): Type =
5260
+ val p = parent.stripAnnots(keep)
5261
+ if keep(annot) then derivedAnnotatedType(p, annot)
5262
+ else p
5289
5263
5290
5264
override def stripped (using Context ): Type = parent.stripped
5291
5265
0 commit comments