@@ -46,7 +46,6 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
46
46
*/
47
47
def transform (ref : SingleDenotation )(implicit ctx : Context ) = ref match {
48
48
case cref @ ShouldTransformDenot (targets) => {
49
- ctx.echo(s " Transforming denot $cref... " )
50
49
val specializedSymbols : Map [Symbol , (Symbol , Symbol )] = (for (SpecializationTarget (target, args, ret, original) <- targets) yield {
51
50
val arity = args.length
52
51
val specializedParent = ctx.getClassIfDefined {
@@ -69,7 +68,6 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
69
68
def specializeApplys (scope : Scope ): Scope = {
70
69
val alteredScope = scope.cloneScope
71
70
specializedSymbols.values.foreach { case (_, apply) =>
72
- println(s " entering: $apply" )
73
71
alteredScope.enter(apply)
74
72
}
75
73
alteredScope
@@ -112,9 +110,17 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
112
110
orig -> (specializedParent, specializedApply)
113
111
}).toMap
114
112
115
- val body = tmpl.body.foldRight(List .empty[Tree ]) {
113
+ val body0 = tmpl.body.foldRight(List .empty[Tree ]) {
116
114
case (tree : DefDef , acc) if tree.name == nme.apply => {
117
- symbolMap.get(tree.symbol).map { case (parent, apply) =>
115
+ val inheritedFrom =
116
+ tree.symbol.allOverriddenSymbols
117
+ .map(_.owner)
118
+ .map(symbolMap.get)
119
+ .flatten
120
+ .toList
121
+ .headOption
122
+
123
+ inheritedFrom.map { case (parent, apply) =>
118
124
val forwardingBody = tpd
119
125
.ref(apply)
120
126
.appliedToArgs(tree.vparamss.head.map(vparam => ref(vparam.symbol)))
@@ -136,7 +142,7 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
136
142
}
137
143
val parents = symbolMap.map { case (_, (parent, _)) => parent }
138
144
139
- cpy.Template (tmpl)(parents = parents.toList, body = body )
145
+ cpy.Template (tmpl)(parents = parents.toList, body = body0 )
140
146
}
141
147
case _ => tree
142
148
}
0 commit comments