File tree 2 files changed +34
-0
lines changed 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ inline def test1 : String = $ { testExpr1 }
4
+ def testExpr1 (using Quotes ): Expr [String ] =
5
+ ' { def f (x : Int ) = 1 ; val n = 2 ; f(n) } match
6
+ case ' { def g (y : Int ) = 1 ; val n = 2 ; $a(g, n): Int } => Expr (a.show)
7
+ case _ => Expr (" not matched" )
8
+
9
+ inline def test2 : String = $ { testExpr2 }
10
+ def testExpr2 (using Quotes ): Expr [String ] =
11
+ ' { def f (x : Int , y: Int ) = 1 ; f(1 , 2 ) } match
12
+ case ' { def g (y : Int , z: Int ) = 1 ; $a(g): Int } => Expr (a.show)
13
+ case _ => Expr (" not matched" )
14
+
15
+ inline def test3 : String = $ { testExpr3 }
16
+ def testExpr3 (using Quotes ): Expr [String ] =
17
+ ' {
18
+ def f1 (using Ordered [Int ]) =
19
+ def f2 (using Ordered [Int ]) =
20
+ 1 < 2
21
+ f2 || 2 < 3 : Boolean
22
+ } match
23
+ case ' {
24
+ def g1 (using ord : Ordered [Int ]) =
25
+ def g2 (using Ordered [Int ]) =
26
+ 1 < 2
27
+ $a(g2, ord): Boolean
28
+ } => Expr (a.show)
29
+ case _ => Expr (" not matched" )
30
+
Original file line number Diff line number Diff line change
1
+ @ main def app =
2
+ println(test1)
3
+ println(test2)
4
+ println(test3)
You can’t perform that action at this time.
0 commit comments