@@ -1112,12 +1112,12 @@ class Definitions {
1112
1112
def apply (args : List [Type ], resultType : Type , isContextual : Boolean = false )(using Context ): Type =
1113
1113
val mt = MethodType .companion(isContextual, false )(args, resultType)
1114
1114
if mt.hasErasedParams then
1115
- RefinedType (ErasedFunctionClass .typeRef, nme.apply, mt)
1115
+ RefinedType (PolyFunctionClass .typeRef, nme.apply, mt)
1116
1116
else
1117
1117
FunctionType (args.length, isContextual).appliedTo(args ::: resultType :: Nil )
1118
1118
def unapply (ft : Type )(using Context ): Option [(List [Type ], Type , Boolean )] = {
1119
1119
ft.dealias match
1120
- case ErasedFunctionOf (mt) =>
1120
+ case PolyFunctionOf (mt : MethodType ) =>
1121
1121
Some (mt.paramInfos, mt.resType, mt.isContextualMethod)
1122
1122
case dft =>
1123
1123
val tsym = dft.typeSymbol
@@ -1129,38 +1129,14 @@ class Definitions {
1129
1129
}
1130
1130
}
1131
1131
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
-
1144
1132
object PolyFunctionOf {
1145
1133
/** Matches a refined `PolyFunction` type and extracts the apply info.
1146
1134
*
1147
- * Pattern: `PolyFunction { def apply: $pt }`
1135
+ * Pattern: `PolyFunction { def apply: $mt }`
1148
1136
*/
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 )
1151
1139
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 ) =>
1164
1140
Some (mt)
1165
1141
case _ => None
1166
1142
}
@@ -1514,9 +1490,6 @@ class Definitions {
1514
1490
lazy val PolyFunctionClass = requiredClass(" scala.PolyFunction" )
1515
1491
def PolyFunctionType = PolyFunctionClass .typeRef
1516
1492
1517
- lazy val ErasedFunctionClass = requiredClass(" scala.runtime.ErasedFunction" )
1518
- def ErasedFunctionType = ErasedFunctionClass .typeRef
1519
-
1520
1493
/** If `cls` is a class in the scala package, its name, otherwise EmptyTypeName */
1521
1494
def scalaClassName (cls : Symbol )(using Context ): TypeName = cls.denot match
1522
1495
case clsd : ClassDenotation if clsd.owner eq ScalaPackageClass =>
@@ -1579,8 +1552,6 @@ class Definitions {
1579
1552
/** Is a synthetic function class
1580
1553
* - FunctionN for N > 22
1581
1554
* - ContextFunctionN for N >= 0
1582
- * - ErasedFunctionN for N > 0
1583
- * - ErasedContextFunctionN for N > 0
1584
1555
*/
1585
1556
def isSyntheticFunctionClass (cls : Symbol ): Boolean = scalaClassName(cls).isSyntheticFunction
1586
1557
@@ -1596,8 +1567,6 @@ class Definitions {
1596
1567
* - FunctionN for 22 > N >= 0 remains as FunctionN
1597
1568
* - ContextFunctionN for N > 22 becomes FunctionXXL
1598
1569
* - ContextFunctionN for N <= 22 becomes FunctionN
1599
- * - ErasedFunctionN becomes Function0
1600
- * - ImplicitErasedFunctionN becomes Function0
1601
1570
* - anything else becomes a NoType
1602
1571
*/
1603
1572
def functionTypeErasure (cls : Symbol ): Type =
@@ -1756,13 +1725,11 @@ class Definitions {
1756
1725
/** Returns whether `tp` is an instance or a refined instance of:
1757
1726
* - scala.FunctionN
1758
1727
* - scala.ContextFunctionN
1759
- * - ErasedFunction
1760
1728
* - PolyFunction
1761
1729
*/
1762
1730
def isFunctionType (tp : Type )(using Context ): Boolean =
1763
1731
isFunctionNType(tp)
1764
1732
|| tp.derivesFrom(defn.PolyFunctionClass ) // TODO check for refinement?
1765
- || tp.derivesFrom(defn.ErasedFunctionClass ) // TODO check for refinement?
1766
1733
1767
1734
private def withSpecMethods (cls : ClassSymbol , bases : List [Name ], paramTypes : Set [TypeRef ]) =
1768
1735
if ! ctx.settings.Yscala2Stdlib .value then
@@ -1866,7 +1833,7 @@ class Definitions {
1866
1833
tp.stripTypeVar.dealias match
1867
1834
case tp1 : TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
1868
1835
asContextFunctionType(TypeComparer .bounds(tp1).hiBound)
1869
- case tp1 @ ErasedFunctionOf (mt) if mt.isContextualMethod =>
1836
+ case tp1 @ PolyFunctionOf (mt : MethodType ) if mt.isContextualMethod =>
1870
1837
tp1
1871
1838
case tp1 =>
1872
1839
if tp1.typeSymbol.name.isContextFunction && isFunctionNType(tp1) then tp1
@@ -1886,21 +1853,14 @@ class Definitions {
1886
1853
atPhase(erasurePhase)(unapply(tp))
1887
1854
else
1888
1855
asContextFunctionType(tp) match
1889
- case ErasedFunctionOf (mt) =>
1856
+ case PolyFunctionOf (mt : MethodType ) =>
1890
1857
Some ((mt.paramInfos, mt.resType, mt.erasedParams))
1891
1858
case tp1 if tp1.exists =>
1892
1859
val args = tp1.functionArgInfos
1893
- val erasedParams = erasedFunctionParameters( tp1)
1860
+ val erasedParams = List .fill(functionArity( tp1)) { false }
1894
1861
Some ((args.init, args.last, erasedParams))
1895
1862
case _ => None
1896
1863
1897
- /* 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
1900
- case tp if isFunctionNType(tp) => List .fill(functionArity(tp)) { false }
1901
- case _ => Nil
1902
- }
1903
-
1904
1864
/** A whitelist of Scala-2 classes that are known to be pure */
1905
1865
def isAssuredNoInits (sym : Symbol ): Boolean =
1906
1866
(sym `eq` SomeClass ) || isTupleClass(sym)
0 commit comments