Skip to content

Commit 126e106

Browse files
committed
Factor out condition
1 parent 2f4d8f6 commit 126e106

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,23 @@ class YCheckPositions extends Phases.Phase {
4545
case Inlined(call, bindings, expansion) =>
4646
bindings.foreach(traverse(_))
4747
sources = call.symbol.topLevelClass.source :: sources
48-
if (
49-
!( // FIXME macro implementations can drop Inlined nodes. We should reinsert them after macro expansion based on the positions of the trees
50-
((ctx.phase <= ctx.typerPhase.next) && call.symbol.is(Macro)) ||
51-
(!(ctx.phase <= ctx.typerPhase.next) && call.symbol.unforcedDecls.exists(_.is(Macro)) || call.symbol.unforcedDecls.toList.exists(_.is(Macro)))
52-
)
53-
) traverse(expansion)(inlineContext(call))
48+
if (!isMacro(call)) // FIXME macro implementations can drop Inlined nodes. We should reinsert them after macro expansion based on the positions of the trees
49+
traverse(expansion)(inlineContext(call))
5450
sources = sources.tail
5551
case _ => traverseChildren(tree)
5652
}
5753
}
5854
}.traverse(tree)
5955
case _ =>
6056
}
57+
}
6158

59+
private def isMacro(call: Tree)(implicit ctx: Context) = {
60+
if (ctx.phase <= ctx.typerPhase.next) call.symbol.is(Macro)
61+
else {
62+
call.symbol.unforcedDecls.exists(_.is(Macro)) ||
63+
call.symbol.unforcedDecls.toList.exists(_.is(Macro))
64+
}
6265
}
6366

6467
}

0 commit comments

Comments
 (0)