Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/run-with-compiler/reflect-sourceCode/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import scala.quoted._
import scala.tasty._

object api {
inline def (x: => T) reflect[T] : String =
${ reflImpl('x) }

private def reflImpl[T](x: Expr[T])(implicit refl: Reflection): Expr[String] = {
import refl._
x.unseal.pos.sourceCode.toExpr
}
}
15 changes: 15 additions & 0 deletions tests/run-with-compiler/reflect-sourceCode/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import api._

object Test {
def f(implicit x: Int): Int = x * x
def main(args: Array[String]): Unit = {
implicit val x: Int = 10
assert(args(0).reflect == "args(0)")
assert(args( 0 ).reflect == "args( 0 )")
assert(args( 0 /* ignore */).reflect == "args( 0 /* ignore */)")
assert(f.reflect == "f")
assert((f).reflect == "f")
assert( { f }.reflect == "{ f }")
assert( { f; f }.reflect == "{ f; f }")
}
}