Skip to content

Commit 5d12a4e

Browse files
committed
use new wildcard type syntax
1 parent e25ef33 commit 5d12a4e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

library/src/scala/quoted/ToExpr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ object ToExpr {
8181
}
8282

8383
/** Default implemetation of `ToExpr[Class[T]]` */
84-
given ClassToExpr[T <: Class[_]]: ToExpr[T] with {
84+
given ClassToExpr[T <: Class[?]]: ToExpr[T] with {
8585
def apply(x: T)(using Quotes) = {
8686
import quotes.reflect._
8787
Ref(defn.Predef_classOf).appliedToType(TypeRepr.typeConstructorOf(x)).asExpr.asInstanceOf[Expr[T]]

tests/run-macros/quoted-toExprOfClass/Macros_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import scala.quoted._
22

3-
inline def wildcard: Map[String, Class[_]] = ${ wildcardMacro }
3+
inline def wildcard: Map[String, Class[?]] = ${ wildcardMacro }
44
inline def noWildcard: Map[String, Class[Int]] = ${ noWildcardMacro }
55

6-
def wildcardMacro(using Quotes): Expr[Map[String, Class[_]]] = {
7-
val result: Map[String, Class[_]] = Map(
6+
def wildcardMacro(using Quotes): Expr[Map[String, Class[?]]] = {
7+
val result: Map[String, Class[?]] = Map(
88
"foo" -> classOf[Long],
99
"bar" -> classOf[Int]
1010
)

tests/run-macros/quoted-toExprOfClass/Test_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
3-
val a: Map[String, Class[_]] = wildcard
3+
val a: Map[String, Class[?]] = wildcard
44
val b: Map[String, Class[Int]] = noWildcard
55
println(a("foo"))
66
println(a("bar"))

0 commit comments

Comments
 (0)