Skip to content

Commit 3467ebc

Browse files
Blaisorbladenicolasstucki
authored andcommitted
Demonstrate regression in scala#4949 for positions of quote-inlined code
1 parent e02c785 commit 3467ebc

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tests/run/i4947e.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
assertImpl: Test$.main(Test_2.scala:7)
2+
true
3+
assertImpl: Test$.main(Test_2.scala:8)
4+
false
5+
assertImpl: Test$.main(Test_2.scala:9)
6+
hi: Test$.main(Test_2.scala:9)
7+
false

tests/run/i4947e/Macro_1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.quoted._
2+
3+
object Macros {
4+
def printStack(tag: String): Unit = {
5+
println(tag + ": "+ new Exception().getStackTrace().apply(1))
6+
}
7+
def assertImpl(expr: Expr[Boolean]) = '{
8+
printStack("assertImpl")
9+
println(~expr)
10+
}
11+
}

tests/run/i4947e/Test_2.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
3+
rewrite def assert2(expr: => Boolean): Unit = ~Macros.assertImpl('(expr))
4+
5+
def main(args: Array[String]): Unit = {
6+
val x = 1
7+
assert2(x != 0)
8+
assert2(x == 0)
9+
assert2 { Macros.printStack("hi"); x == 0 }
10+
}
11+
}

0 commit comments

Comments
 (0)