@@ -105,10 +105,7 @@ class SpecializeFunctions extends MiniPhase with InfoTransformer {
105
105
/** Dispatch to specialized `apply`s in user code when available */
106
106
override def transformApply (tree : Apply )(using Context ) =
107
107
tree match {
108
- case Apply (fun, args)
109
- if fun.symbol.name == nme.apply &&
110
- derivesFromFn012(fun.symbol.owner)
111
- =>
108
+ case Apply (fun, args) if fun.symbol.name == nme.apply =>
112
109
val paramTypes = (fun.tpe.widen.firstParamTypes :+ tree.tpe).map(_.widenSingleton.dealias)
113
110
val isSpecializable =
114
111
defn.isSpecializableFunction(
@@ -117,23 +114,22 @@ class SpecializeFunctions extends MiniPhase with InfoTransformer {
117
114
paramTypes.last
118
115
)
119
116
120
- if (isSpecializable && ! paramTypes.exists(_.isInstanceOf [ExprType ])) {
121
- val specializedApply = specializedName(nme.apply, paramTypes)
122
- val newSel = fun match {
123
- case Select (qual, _) =>
124
- qual.select(specializedApply)
125
- case _ =>
126
- (fun.tpe: @ unchecked) match {
127
- case TermRef (prefix : ThisType , name) =>
128
- tpd.This (prefix.cls).select(specializedApply)
129
- case TermRef (prefix : NamedType , name) =>
130
- tpd.ref(prefix).select(specializedApply)
131
- }
132
- }
133
-
134
- newSel.appliedToArgs(args)
117
+ if (! isSpecializable || paramTypes.exists(_.isInstanceOf [ExprType ])) return tree
118
+
119
+ val specializedApply = specializedName(nme.apply, paramTypes)
120
+ val newSel = fun match {
121
+ case Select (qual, _) =>
122
+ qual.select(specializedApply)
123
+ case _ =>
124
+ (fun.tpe: @ unchecked) match {
125
+ case TermRef (prefix : ThisType , name) =>
126
+ tpd.This (prefix.cls).select(specializedApply)
127
+ case TermRef (prefix : NamedType , name) =>
128
+ tpd.ref(prefix).select(specializedApply)
129
+ }
135
130
}
136
- else tree
131
+
132
+ newSel.appliedToArgs(args)
137
133
138
134
case _ => tree
139
135
}
0 commit comments