@@ -22,23 +22,26 @@ class SpecializeFunctions extends MiniPhase {
22
22
/** Create forwarders from the generic applys to the specialized ones.
23
23
*/
24
24
override def transformDefDef (ddef : DefDef )(using Context ) = {
25
- val sym = ddef.symbol
26
-
27
25
if ddef.name != nme.apply
28
- || sym.is(Flags .Deferred )
29
26
|| ddef.vparamss.length != 1
30
27
|| ddef.vparamss.head.length > 2
31
- || ! sym .owner.isClass
28
+ || ! ctx .owner.isClass
32
29
then
33
30
return ddef
34
31
35
- val cls = sym.owner.asClass
36
- val paramTypes = ddef.vparamss.head.map(_.symbol.info)
37
- val retType = sym.info.finalResultType
38
- val specName = nme.apply.specializedFunction(retType, paramTypes)
32
+ val sym = ddef.symbol
33
+ val cls = ctx.owner.asClass
34
+
35
+ var specName : Name = null
36
+
37
+ def isSpecializable = {
38
+ val paramTypes = ddef.vparamss.head.map(_.symbol.info)
39
+ val retType = sym.info.finalResultType
40
+ specName = nme.apply.specializedFunction(retType, paramTypes)
41
+ defn.isSpecializableFunction(cls, paramTypes, retType)
42
+ }
39
43
40
- val isSpecializable = defn.isSpecializableFunction(cls, paramTypes, retType)
41
- if (! isSpecializable || cls.info.decls.lookup(specName).exists) return ddef
44
+ if (sym.is(Flags .Deferred ) || ! isSpecializable) return ddef
42
45
43
46
val specializedApply = newSymbol(
44
47
cls,
0 commit comments