@@ -1114,7 +1114,7 @@ class Definitions {
1114
1114
FunctionType (args.length, isContextual).appliedTo(args ::: resultType :: Nil )
1115
1115
def unapply (ft : Type )(using Context ): Option [(List [Type ], Type , Boolean )] = {
1116
1116
ft.dealias match
1117
- case PolyOrErasedFunctionOf (mt : MethodType ) =>
1117
+ case ErasedFunctionOf (mt) =>
1118
1118
Some (mt.paramInfos, mt.resType, mt.isContextualMethod)
1119
1119
case _ =>
1120
1120
val tsym = ft.dealias.typeSymbol
@@ -1138,6 +1138,18 @@ class Definitions {
1138
1138
case _ => None
1139
1139
}
1140
1140
1141
+ object ErasedFunctionOf {
1142
+ /** Matches a refined `ErasedFunction` type and extracts the apply info.
1143
+ *
1144
+ * Pattern: `ErasedFunction { def apply: $mt }`
1145
+ */
1146
+ def unapply (ft : Type )(using Context ): Option [MethodType ] = ft.dealias match
1147
+ case RefinedType (parent, nme.apply, mt : MethodType )
1148
+ if parent.derivesFrom(defn.ErasedFunctionClass ) =>
1149
+ Some (mt)
1150
+ case _ => None
1151
+ }
1152
+
1141
1153
object PartialFunctionOf {
1142
1154
def apply (arg : Type , result : Type )(using Context ): Type =
1143
1155
PartialFunctionClass .typeRef.appliedTo(arg :: result :: Nil )
@@ -1838,7 +1850,7 @@ class Definitions {
1838
1850
tp.stripTypeVar.dealias match
1839
1851
case tp1 : TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
1840
1852
asContextFunctionType(TypeComparer .bounds(tp1).hiBound)
1841
- case tp1 @ PolyOrErasedFunctionOf (mt : MethodType ) if mt.isContextualMethod =>
1853
+ case tp1 @ ErasedFunctionOf (mt) if mt.isContextualMethod =>
1842
1854
tp1
1843
1855
case tp1 =>
1844
1856
if tp1.typeSymbol.name.isContextFunction && isFunctionNType(tp1) then tp1
@@ -1858,7 +1870,7 @@ class Definitions {
1858
1870
atPhase(erasurePhase)(unapply(tp))
1859
1871
else
1860
1872
asContextFunctionType(tp) match
1861
- case PolyOrErasedFunctionOf (mt : MethodType ) =>
1873
+ case ErasedFunctionOf (mt) =>
1862
1874
Some ((mt.paramInfos, mt.resType, mt.erasedParams))
1863
1875
case tp1 if tp1.exists =>
1864
1876
val args = tp1.functionArgInfos
@@ -1868,7 +1880,7 @@ class Definitions {
1868
1880
1869
1881
/* Returns a list of erased booleans marking whether parameters are erased, for a function type. */
1870
1882
def erasedFunctionParameters (tp : Type )(using Context ): List [Boolean ] = tp.dealias match {
1871
- case RefinedType (parent, nme.apply, mt : MethodType ) => mt.erasedParams
1883
+ case ErasedFunctionOf (mt ) => mt.erasedParams
1872
1884
case tp if isFunctionNType(tp) => List .fill(functionArity(tp)) { false }
1873
1885
case _ => Nil
1874
1886
}
0 commit comments