File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ long
2
+ int
3
+ int
4
+ int
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ inline def wildcard : Map [String , Class [_]] = $ { wildcardMacro }
4
+ inline def noWildcard : Map [String , Class [Int ]] = $ { noWildcardMacro }
5
+
6
+ def wildcardMacro (using Quotes ): Expr [Map [String , Class [_]]] = {
7
+ val result : Map [String , Class [_]] = Map (
8
+ " foo" -> classOf [Long ],
9
+ " bar" -> classOf [Int ]
10
+ )
11
+ Expr (result)
12
+ }
13
+
14
+ def noWildcardMacro (using Quotes ): Expr [Map [String , Class [Int ]]] = {
15
+ val result : Map [String , Class [Int ]] = Map (
16
+ " foo" -> classOf [Int ],
17
+ " bar" -> classOf [Int ]
18
+ )
19
+ Expr (result)
20
+ }
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def main (args : Array [String ]): Unit = {
3
+ val a : Map [String , Class [_]] = wildcard
4
+ val b : Map [String , Class [Int ]] = noWildcard
5
+ println(a(" foo" ))
6
+ println(a(" bar" ))
7
+ println(b(" foo" ))
8
+ println(b(" bar" ))
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments