Skip to content

Commit 2660b09

Browse files
authored
-Yprofile-trace properly report macro splicing source (#23488)
2 parents 8598403 + 7f81cc5 commit 2660b09

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,9 +1144,10 @@ class Inliner(val call: tpd.Tree)(using Context):
11441144
else
11451145
ctx.compilationUnit.suspend(hints.nn.toList.mkString(", ")) // this throws a SuspendException
11461146

1147-
val evaluatedSplice = inContext(quoted.MacroExpansion.context(inlinedFrom)) {
1148-
Splicer.splice(body, splicePos, inlinedFrom.srcPos, MacroClassLoader.fromContext)
1149-
}
1147+
val evaluatedSplice =
1148+
inContext(quoted.MacroExpansion.context(inlinedFrom)):
1149+
ctx.profiler.onMacroSplice(inlinedFrom.symbol):
1150+
Splicer.splice(body, splicePos, inlinedFrom.srcPos, MacroClassLoader.fromContext)
11501151
val inlinedNormalizer = new TreeMap {
11511152
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
11521153
case tree @ Inlined(_, Nil, expr) if tree.inlinedFromOuterScope && enclosingInlineds.isEmpty => transform(expr)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object Splicer {
5353
inContext(sliceContext) {
5454
val oldContextClassLoader = Thread.currentThread().getContextClassLoader
5555
Thread.currentThread().setContextClassLoader(classLoader)
56-
try ctx.profiler.onMacroSplice(owner){
56+
try {
5757
val interpreter = new SpliceInterpreter(splicePos, classLoader)
5858

5959
// Some parts of the macro are evaluated during the unpickling performed in quotedExprToTree

0 commit comments

Comments
 (0)