Skip to content

Commit cc04eaf

Browse files
authored
Merge pull request #8119 from dotty-staging/fix-#7025
Fix #7025: Add regression test
2 parents 51b1f2c + f4bd25f commit cc04eaf

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/run-macros/i7025/Macros_1.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
object Macros {
2+
import scala.quoted._
3+
4+
inline def debug: Unit = ${Macros.debugImpl}
5+
6+
def debugImpl with (qctx: QuoteContext): Expr[Unit] = {
7+
import qctx.tasty.{given, _}
8+
9+
def nearestEnclosingDef(owner: Symbol): Symbol =
10+
if owner.isClassDef then owner
11+
else nearestEnclosingDef(owner.owner)
12+
13+
val x = nearestEnclosingDef(rootContext.owner)
14+
if x.isDefDef then
15+
val code = x.signature.toString
16+
'{ println(${Expr(code)}) }
17+
else
18+
'{()}
19+
}
20+
}

tests/run-macros/i7025/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+
def main(args: Array[String]): Unit = {
3+
bar("world", 100, true)
4+
}
5+
6+
def bar(a1: String, a2: Long, a3: Boolean) = {
7+
Macros.debug
8+
}
9+
}

0 commit comments

Comments
 (0)