classOf[] 用于更高级的类型

classOf[] for a higher-kinded type

给定 class Foo[F[_]],我如何获得 Class 对象?通常的语法不起作用:

scala> classOf[Foo[_]]
<console>:9: error: _ takes no type parameters, expected: one
              classOf[Foo[_]]
                          ^

也没有

scala> classOf[Foo[_[_]]]
<console>:9: error: _ does not take type parameters
              classOf[Foo[_[_]]]
                          ^

啊,对了。留下这个以防有人找它:

scala> classOf[Foo[F] forSome { type F[_] }]
warning: there were 1 feature warning(s); re-run with -feature for details
res0: Class[Foo[_[_] <: Any]] = class Foo