Skip to content

Commit 0225fe9

Browse files
authored
Merge pull request #9490 from dotty-staging/fix-#9475
Fix #9475: Add regression test
2 parents 0cdf13a + 064fc80 commit 0225fe9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/run-macros/i9475/Macro_1.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import scala.quoted._
3+
4+
object Exp {
5+
6+
private def compileImpl(e: Expr[Int], env: Map[String, Expr[Int]])(using QuoteContext): Expr[Int] = {
7+
e match {
8+
case '{$s:Int} => s
9+
case exp =>
10+
compileImpl(exp, env)
11+
}
12+
}
13+
14+
private def compileUnlift(e: Expr[Int])(using QuoteContext): Expr[Int] = {
15+
val environment = Map[String, Expr[Int]]()
16+
compileImpl(e, environment)
17+
}
18+
19+
inline def compile(inline expr: Int): Int = {
20+
${compileUnlift('expr)}
21+
}
22+
23+
}

tests/run-macros/i9475/Test_2.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
3+
def main(args: Array[String]): Unit = {
4+
println("Hello world!")
5+
6+
println(Exp.compile(3))
7+
}
8+
9+
}

0 commit comments

Comments
 (0)