简体   繁体   中英

classOf[] for a higher-kinded type

Given class Foo[F[_]] , how do I get the Class object? The usual syntax doesn't work:

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

Neither does

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

Ah, right. Leaving this in case someone looks for it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM