unable to use an intersection type when notional class requires access modification

对着背影说爱祢 提交于 2019-12-04 06:31:39

This looks like a javac bug.

http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4

The members of a type variable X with bound T & I1 & ... & In are the members of the intersection type (§4.9) T & I1 & ... & In

http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.9

Every intersection type T1 & ... & Tn induces a notional class or interface for the purpose of identifying the members of the intersection type ...

If Ck is Object, a notional interface is induced ... has direct superinterfaces T1', ..., Tn'

Therefore, for PublicCloneable & HasPosition, a notional interface is introduced, extending both of them, which should be OK.

As the first error is trying to tell you, your code cannot work, because you're constraining to types with two incompatible signatures for the clone() method.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!