@@ -34,24 +34,24 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
34
34
atNextPhase(newSymbol(sym, name, Flags .Method , MethodType (args, ret)))
35
35
}
36
36
37
- private def specFun0 (op : Type => Unit )(using Context ): Unit = {
37
+ private inline def specFun0 (inline op : Type => Unit )(using Context ): Unit = {
38
38
for (r <- defn.Function0SpecializedReturnTypes ) do
39
39
op(r)
40
40
}
41
41
42
- private def specFun1 (op : (Type , Type ) => Unit )(using Context ): Unit = {
42
+ private inline def specFun1 (inline op : (Type , Type ) => Unit )(using Context ): Unit = {
43
43
for
44
44
r <- defn.Function1SpecializedReturnTypes
45
45
t1 <- defn.Function1SpecializedParamTypes
46
46
do
47
47
op(t1, r)
48
48
}
49
49
50
- private def specFun2 (op : (Type , Type , Type ) => Unit )(using Context ): Unit = {
50
+ private inline def specFun2 (inline op : (Type , Type , Type ) => Unit )(using Context ): Unit = {
51
51
for
52
52
r <- defn.Function2SpecializedReturnTypes
53
53
t1 <- defn.Function2SpecializedParamTypes
54
- t2 <- defn.Function2SpecializedReturnTypes
54
+ t2 <- defn.Function2SpecializedParamTypes
55
55
do
56
56
op(t1, t2, r)
57
57
}
@@ -63,30 +63,29 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
63
63
64
64
/** Add symbols for specialized methods to FunctionN */
65
65
override def transformInfo (tp : Type , sym : Symbol )(using Context ) = tp match {
66
- // case tp: ClassInfo =>
67
- // if sym == defn.SpecializableFunctions(0) then
68
- // val scope = tp.decls.cloneScope
69
- // specFun0 { r => scope.enter(specApplySymbol(sym, Nil, r)) }
70
- // tp.derivedClassInfo(decls = scope)
66
+ case tp : ClassInfo =>
67
+ if sym == defn.SpecializableFunctions (0 ) then
68
+ val scope = tp.decls.cloneScope
69
+ specFun0 { r => scope.enter(specApplySymbol(sym, Nil , r)) }
70
+ tp.derivedClassInfo(decls = scope)
71
71
72
- // else if sym == defn.SpecializableFunctions(1) then
73
- // val scope = tp.decls.cloneScope
74
- // specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, List(t1) , r)) }
75
- // tp.derivedClassInfo(decls = scope)
72
+ else if sym == defn.SpecializableFunctions (1 ) then
73
+ val scope = tp.decls.cloneScope
74
+ specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, t1 :: Nil , r)) }
75
+ tp.derivedClassInfo(decls = scope)
76
76
77
- // else if sym == defn.SpecializableFunctions(2) then
78
- // val scope = tp.decls.cloneScope
79
- // specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, List(t1, t2) , r)) }
80
- // tp.derivedClassInfo(decls = scope)
77
+ else if sym == defn.SpecializableFunctions (2 ) then
78
+ val scope = tp.decls.cloneScope
79
+ specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, t1 :: t2 :: Nil , r)) }
80
+ tp.derivedClassInfo(decls = scope)
81
81
82
- // else tp
82
+ else tp
83
83
84
84
case _ => tp
85
85
}
86
86
87
87
/** Create bridge methods for FunctionN with specialized applys */
88
- // override def transformTemplate(tree: Template)(using Context) = {
89
- def transformTemplate1 (tree : Template )(using Context ) = {
88
+ override def transformTemplate (tree : Template )(using Context ) = {
90
89
val cls = tree.symbol.owner.asClass
91
90
92
91
def synthesizeApply (names : collection.Set [TermName ]): Tree = {
0 commit comments