@@ -34,22 +34,25 @@ class SpecializeFunctions extends MiniPhase with InfoTransformer {
34
34
while (arity < 3 ) {
35
35
val func = defn.FunctionClass (arity)
36
36
if (sym.derivesFrom(func)) {
37
- val baseType = tp.cls.typeRef.baseType(func)
38
- val apply = baseType.member(nme.apply)
39
-
37
+ val baseType = tp.cls.typeRef.baseType(func)
40
38
val paramTypes = baseType.argInfos
41
- val argTypes = paramTypes.init
42
- val retType = paramTypes.last
39
+ val argTypes = paramTypes.init
40
+ val retType = paramTypes.last
41
+
42
+ val apply = baseType.member(nme.apply)
43
+ val overrideApply = tp.decls.find { sym =>
44
+ sym.is(Flags .Method ) && sym.name == nme.apply && sym.info.matches(apply.info)
45
+ }
43
46
44
- val isSpecializable = defn.isSpecializableFunction(sym.asClass, argTypes, retType)
47
+ def isSpecializable = defn.isSpecializableFunction(sym.asClass, argTypes, retType)
45
48
46
- if (isSpecializable) {
49
+ if (overrideApply.exists && isSpecializable) {
47
50
val specializedMethodName : Name = nme.apply.specializedFunction(retType, argTypes)
48
51
val applySpecialized = newSymbol(
49
52
sym,
50
53
specializedMethodName,
51
- Flags . Override | Flags . Method | Flags .Synthetic ,
52
- apply .info
54
+ overrideApply.flags | Flags .Synthetic ,
55
+ overrideApply .info
53
56
)
54
57
55
58
newApplys += applySpecialized
0 commit comments