Skip to content

Commit e25ef33

Browse files
committed
add test case
1 parent da66029 commit e25ef33

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
long
2+
int
3+
int
4+
int
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

0 commit comments

Comments
 (0)