[英]classOf[] for a higher-kinded type
給定class Foo[F[_]]
,如何獲取Class
對象? 常用語法不起作用:
scala> classOf[Foo[_]]
<console>:9: error: _$1 takes no type parameters, expected: one
classOf[Foo[_]]
^
也沒有
scala> classOf[Foo[_[_]]]
<console>:9: error: _$1 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.