@@ -560,21 +560,19 @@ object TypeErasure {
560560 case _ => false
561561 }
562562
563- /** The erasure of `PolyFunction { def apply: $applyInfo }` */
564- def erasePolyFunctionApply (applyInfo : Type )(using Context ): Type =
565- assert(applyInfo.isInstanceOf [PolyType ])
566- val res = applyInfo.resultType
567- val paramss = res.paramNamess
568- assert(paramss.length == 1 )
569- erasure(defn.FunctionType (paramss.head.length,
570- isContextual = res.isImplicitMethod))
571-
572- def eraseErasedFunctionApply (erasedFn : MethodType )(using Context ): Type =
573- val fnType = defn.FunctionType (
574- n = erasedFn.erasedParams.count(_ == false ),
575- isContextual = erasedFn.isContextualMethod,
576- )
577- erasure(fnType)
563+ /** The erasure of `(PolyFunction | ErasedFunction) { def apply: $applyInfo }` */
564+ def eraseRefinedFunctionApply (applyInfo : Type )(using Context ): Type =
565+ def functionType (info : Type ): Type = info match {
566+ case info : PolyType =>
567+ functionType(info.resultType)
568+ case info : MethodType =>
569+ assert(! info.resultType.isInstanceOf [MethodicType ])
570+ defn.FunctionType (
571+ n = info.erasedParams.count(_ == false ),
572+ isContextual = info.isImplicitMethod,
573+ )
574+ }
575+ erasure(functionType(applyInfo))
578576}
579577
580578import TypeErasure ._
@@ -659,10 +657,8 @@ class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConst
659657 else SuperType (eThis, eSuper)
660658 case ExprType (rt) =>
661659 defn.FunctionType (0 )
662- case RefinedType (parent, nme.apply, refinedInfo) if defn.isPolyFunctionType(parent) =>
663- erasePolyFunctionApply(refinedInfo)
664- case RefinedType (parent, nme.apply, refinedInfo : MethodType ) if defn.isErasedFunctionType(parent) =>
665- eraseErasedFunctionApply(refinedInfo)
660+ case RefinedType (parent, nme.apply, refinedInfo) if defn.isRefinedFunctionType(parent) =>
661+ eraseRefinedFunctionApply(refinedInfo)
666662 case tp : TypeVar if ! tp.isInstantiated =>
667663 assert(inSigName, i " Cannot erase uninstantiated type variable $tp" )
668664 WildcardType
0 commit comments