@@ -105,10 +105,12 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
105
105
ctx.requiredClassRef(functionPkg ++ specializedName(functionName ++ arity, args, ret))
106
106
}
107
107
val specializedMethodName = specializedName(nme.apply, args, ret)
108
- val specializedApply = ctx.owner.info.decls.lookup(specializedMethodName).asTerm
108
+ val specializedApply = ctx.owner.info.decls.lookup(specializedMethodName)
109
109
110
- orig -> (specializedParent, specializedApply)
111
- }).toMap
110
+ if (specializedApply.exists)
111
+ Some (orig -> (specializedParent, specializedApply.asTerm))
112
+ else None
113
+ }).flatten.toMap
112
114
113
115
val body0 = tmpl.body.foldRight(List .empty[Tree ]) {
114
116
case (tree : DefDef , acc) if tree.name == nme.apply => {
@@ -140,9 +142,15 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
140
142
}
141
143
case (tree, acc) => tree :: acc
142
144
}
143
- val parents = symbolMap.map { case (_, (parent, _)) => parent }
144
145
145
- cpy.Template (tmpl)(parents = parents.toList, body = body0)
146
+ val specializedParents = tree.parents.map { t =>
147
+ symbolMap
148
+ .get(t.symbol)
149
+ .map { case (newSym, _) => newSym }
150
+ .getOrElse(t)
151
+ }
152
+
153
+ cpy.Template (tmpl)(parents = specializedParents, body = body0)
146
154
}
147
155
case _ => tree
148
156
}
0 commit comments