File tree 2 files changed +27
-0
lines changed
tests/run-with-compiler/reflect-sourceCode 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+ import scala .tasty ._
3
+
4
+ object api {
5
+ inline def (x : => T ) reflect[T ] : String =
6
+ $ { reflImpl(' x ) }
7
+
8
+ private def reflImpl [T ](x : Expr [T ])(implicit refl : Reflection ): Expr [String ] = {
9
+ import refl ._
10
+ x.unseal.pos.sourceCode.toExpr
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ import api ._
2
+
3
+ object Test {
4
+ def f (implicit x : Int ): Int = x * x
5
+ def main (args : Array [String ]): Unit = {
6
+ implicit val x : Int = 10
7
+ assert(args(0 ).reflect == " args(0)" )
8
+ assert(args( 0 ).reflect == " args( 0 )" )
9
+ assert(args( 0 /* ignore */ ).reflect == " args( 0 /* ignore */)" )
10
+ assert(f.reflect == " f" )
11
+ assert((f).reflect == " f" )
12
+ assert( { f }.reflect == " { f }" )
13
+ assert( { f; f }.reflect == " { f; f }" )
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments