Skip to content

Commit 7ab2842

Browse files
committed
Fix unapply of ShouldTransformTree
1 parent b494b6b commit 7ab2842

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/src/dotty/tools/dotc/transform/SpecializeFunction1.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
4646
*/
4747
def transform(ref: SingleDenotation)(implicit ctx: Context) = ref match {
4848
case cref @ ShouldTransformDenot(targets) => {
49+
ctx.echo(s"Transforming denot $cref...")
4950
val specializedSymbols: Map[Symbol, (Symbol, Symbol)] = (for (SpecializationTarget(target, args, ret, original) <- targets) yield {
5051
val arity = args.length
5152
val specializedParent = ctx.getClassIfDefined {
@@ -171,12 +172,10 @@ class SpecializeFunction1 extends MiniPhaseTransform with DenotTransformer {
171172

172173
private object ShouldTransformTree {
173174
def unapply(tree: Template)(implicit ctx: Context): Option[Seq[(Tree, SpecializationTarget)]] = {
174-
val targets = getSpecTargets(tree.tpe)
175-
val treeToTargets =
176-
tree.parents.filter(t => defn.isFunctionClass(t.symbol)).map { tree =>
177-
targets.find(_.original eq tree.symbol).map(target => (tree, target))
178-
}
179-
.flatten
175+
val treeToTargets = tree.parents
176+
.map(t => (t, getSpecTargets(t.tpe)))
177+
.filter(_._2.nonEmpty)
178+
.map { case (t, xs) => (t, xs.head) }
180179

181180
if (treeToTargets.isEmpty) None else Some(treeToTargets)
182181
}

0 commit comments

Comments
 (0)