We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 51b1f2c + f4bd25f commit cc04eafCopy full SHA for cc04eaf
tests/run-macros/i7025/Macros_1.scala
@@ -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
@@ -0,0 +1,9 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ bar("world", 100, true)
+ def bar(a1: String, a2: Long, a3: Boolean) = {
+ Macros.debug
0 commit comments