Skip to content

Commit d743501

Browse files
authored
Merge pull request #492 from scala/backport-lts-3.3-23488
Backport "-Yprofile-trace properly report macro splicing source" to 3.3 LTS
2 parents 2019aab + 6230788 commit d743501

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,9 +1098,10 @@ class Inliner(val call: tpd.Tree)(using Context):
10981098
if suspendable then
10991099
ctx.compilationUnit.suspend() // this throws a SuspendException
11001100

1101-
val evaluatedSplice = inContext(quoted.MacroExpansion.context(inlinedFrom)) {
1102-
Splicer.splice(body, splicePos, inlinedFrom.srcPos, MacroClassLoader.fromContext)
1103-
}
1101+
val evaluatedSplice =
1102+
inContext(quoted.MacroExpansion.context(inlinedFrom)):
1103+
ctx.profiler.onMacroSplice(inlinedFrom.symbol):
1104+
Splicer.splice(body, splicePos, inlinedFrom.srcPos, MacroClassLoader.fromContext)
11041105
val inlinedNormalizer = new TreeMap {
11051106
override def transform(tree: tpd.Tree)(using Context): tpd.Tree = tree match {
11061107
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
@@ -54,7 +54,7 @@ object Splicer {
5454
inContext(sliceContext) {
5555
val oldContextClassLoader = Thread.currentThread().getContextClassLoader
5656
Thread.currentThread().setContextClassLoader(classLoader)
57-
try ctx.profiler.onMacroSplice(owner){
57+
try {
5858
val interpreter = new SpliceInterpreter(splicePos, classLoader)
5959

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

tests/neg/i13044.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- [E172] Type Error: tests/neg/i13044.scala:46:40 ---------------------------------------------------------------------
1+
-- [E172] Type Error: tests/neg/i13044.scala:61:40 ---------------------------------------------------------------------
22
61 | implicit def typeSchema: Schema[A] = Schema.gen // error
33
| ^^^^^^^^^^
44
| No given instance of type Schema[B] was found.

tests/neg/i13044.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,22 @@ trait SchemaDerivation {
3333
inline given gen[A]: Schema[A] = derived
3434
}
3535

36-
case class H(i: Int)
36+
case class X15(i: Int)
37+
case class X14(i: X15)
38+
case class X13(i: X14)
39+
case class X12(i: X13)
40+
case class X11(i: X12)
41+
case class X10(i: X11)
42+
case class X9(i: X10)
43+
case class X8(i: X9)
44+
case class X7(i: X8)
45+
case class X6(i: X7)
46+
case class X5(i: X6)
47+
case class X4(i: X5)
48+
case class X3(i: X4)
49+
case class X2(i: X3)
50+
case class X1(i: X2)
51+
case class H(i: X1)
3752
case class G(h: H)
3853
case class F(g: G)
3954
case class E(f: Option[F])

0 commit comments

Comments
 (0)