使用嵌套的类型参数作为顶级类型参数 [英] Using a nested type parameter as a toplevel type parameter
本文介绍了使用嵌套的类型参数作为顶级类型参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下泛型类型两次包含类型参数 A
:
The following generic type contains the type parameter A
two times:
class Something<B<A>, A>
我想知道是否可能只编写 Class SomethingB
,因为 A
已经通过 B< A>
.
I wonder if it would be possible to write only class Something<B<A>>
because A
is already given through B<A>
.
我认为这是不可能的,但是也许我忽略了某些事情.
I think it is not possible, but maybe I've overlooked something.
推荐答案
要正式回答这个问题:编译器无法以这种方式推断类型.
To answer the question officially: The compiler cannot infer the type this way.
这篇关于使用嵌套的类型参数作为顶级类型参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文