@@ -1112,12 +1112,12 @@ class Definitions {
11121112 def apply (args : List [Type ], resultType : Type , isContextual : Boolean = false )(using Context ): Type =
11131113 val mt = MethodType .companion(isContextual, false )(args, resultType)
11141114 if mt.hasErasedParams then
1115- RefinedType (ErasedFunctionClass .typeRef, nme.apply, mt)
1115+ RefinedType (PolyFunctionClass .typeRef, nme.apply, mt)
11161116 else
11171117 FunctionType (args.length, isContextual).appliedTo(args ::: resultType :: Nil )
11181118 def unapply (ft : Type )(using Context ): Option [(List [Type ], Type , Boolean )] = {
11191119 ft.dealias match
1120- case ErasedFunctionOf (mt) =>
1120+ case PolyFunctionOf (mt : MethodType ) =>
11211121 Some (mt.paramInfos, mt.resType, mt.isContextualMethod)
11221122 case dft =>
11231123 val tsym = dft.typeSymbol
@@ -1129,38 +1129,14 @@ class Definitions {
11291129 }
11301130 }
11311131
1132- object PolyOrErasedFunctionOf {
1133- /** Matches a refined `PolyFunction` or `ErasedFunction` type and extracts the apply info.
1134- *
1135- * Pattern: `(PolyFunction | ErasedFunction) { def apply: $mt }`
1136- */
1137- def unapply (ft : Type )(using Context ): Option [MethodicType ] = ft.dealias match
1138- case RefinedType (parent, nme.apply, mt : MethodicType )
1139- if parent.derivesFrom(defn.PolyFunctionClass ) || parent.derivesFrom(defn.ErasedFunctionClass ) =>
1140- Some (mt)
1141- case _ => None
1142- }
1143-
11441132 object PolyFunctionOf {
11451133 /** Matches a refined `PolyFunction` type and extracts the apply info.
11461134 *
1147- * Pattern: `PolyFunction { def apply: $pt }`
1135+ * Pattern: `PolyFunction { def apply: $mt }`
11481136 */
1149- def unapply (ft : Type )(using Context ): Option [PolyType ] = ft.dealias match
1150- case RefinedType (parent, nme.apply, pt : PolyType )
1137+ def unapply (ft : Type )(using Context ): Option [MethodicType ] = ft.dealias match
1138+ case RefinedType (parent, nme.apply, mt : MethodicType )
11511139 if parent.derivesFrom(defn.PolyFunctionClass ) =>
1152- Some (pt)
1153- case _ => None
1154- }
1155-
1156- object ErasedFunctionOf {
1157- /** Matches a refined `ErasedFunction` type and extracts the apply info.
1158- *
1159- * Pattern: `ErasedFunction { def apply: $mt }`
1160- */
1161- def unapply (ft : Type )(using Context ): Option [MethodType ] = ft.dealias match
1162- case RefinedType (parent, nme.apply, mt : MethodType )
1163- if parent.derivesFrom(defn.ErasedFunctionClass ) =>
11641140 Some (mt)
11651141 case _ => None
11661142 }
@@ -1514,9 +1490,6 @@ class Definitions {
15141490 lazy val PolyFunctionClass = requiredClass(" scala.PolyFunction" )
15151491 def PolyFunctionType = PolyFunctionClass .typeRef
15161492
1517- lazy val ErasedFunctionClass = requiredClass(" scala.runtime.ErasedFunction" )
1518- def ErasedFunctionType = ErasedFunctionClass .typeRef
1519-
15201493 /** If `cls` is a class in the scala package, its name, otherwise EmptyTypeName */
15211494 def scalaClassName (cls : Symbol )(using Context ): TypeName = cls.denot match
15221495 case clsd : ClassDenotation if clsd.owner eq ScalaPackageClass =>
@@ -1756,13 +1729,11 @@ class Definitions {
17561729 /** Returns whether `tp` is an instance or a refined instance of:
17571730 * - scala.FunctionN
17581731 * - scala.ContextFunctionN
1759- * - ErasedFunction
17601732 * - PolyFunction
17611733 */
17621734 def isFunctionType (tp : Type )(using Context ): Boolean =
17631735 isFunctionNType(tp)
17641736 || tp.derivesFrom(defn.PolyFunctionClass ) // TODO check for refinement?
1765- || tp.derivesFrom(defn.ErasedFunctionClass ) // TODO check for refinement?
17661737
17671738 private def withSpecMethods (cls : ClassSymbol , bases : List [Name ], paramTypes : Set [TypeRef ]) =
17681739 if ! ctx.settings.Yscala2Stdlib .value then
@@ -1866,7 +1837,7 @@ class Definitions {
18661837 tp.stripTypeVar.dealias match
18671838 case tp1 : TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
18681839 asContextFunctionType(TypeComparer .bounds(tp1).hiBound)
1869- case tp1 @ ErasedFunctionOf (mt) if mt.isContextualMethod =>
1840+ case tp1 @ PolyFunctionOf (mt : MethodType ) if mt.isContextualMethod =>
18701841 tp1
18711842 case tp1 =>
18721843 if tp1.typeSymbol.name.isContextFunction && isFunctionNType(tp1) then tp1
@@ -1886,17 +1857,17 @@ class Definitions {
18861857 atPhase(erasurePhase)(unapply(tp))
18871858 else
18881859 asContextFunctionType(tp) match
1889- case ErasedFunctionOf (mt) =>
1860+ case PolyFunctionOf (mt : MethodType ) =>
18901861 Some ((mt.paramInfos, mt.resType, mt.erasedParams))
18911862 case tp1 if tp1.exists =>
18921863 val args = tp1.functionArgInfos
1893- val erasedParams = erasedFunctionParameters(tp1)
1864+ val erasedParams = erasedFunctionParameters(tp1) // TODO this seems to alwas be a list of false
18941865 Some ((args.init, args.last, erasedParams))
18951866 case _ => None
18961867
18971868 /* Returns a list of erased booleans marking whether parameters are erased, for a function type. */
1898- def erasedFunctionParameters (tp : Type )(using Context ): List [Boolean ] = tp.dealias match {
1899- case ErasedFunctionOf (mt) => mt.erasedParams
1869+ def erasedFunctionParameters (tp : Type )(using Context ): List [Boolean ] = tp.dealias match { // TODO remove
1870+ case PolyFunctionOf (mt : MethodType ) => mt.erasedParams
19001871 case tp if isFunctionNType(tp) => List .fill(functionArity(tp)) { false }
19011872 case _ => Nil
19021873 }
0 commit comments