如何解决在eclipse中使用泛型密封接口
以下内容是合法的(即我可以对其进行编译),并且可以在Java 15中启用预览功能(在eclipse 2020-09中使用)
public sealed interface Quantity<T> permits QuantityImpl { }
public record QuantityImpl<T extends Number>(T value) implements Quantity<T> { }
public class Play {
public static void main(String[] args) {
Quantity<Float> q = new QuantityImpl<>(3.0f);
System.out.println(q instanceof Quantity);
}
}
但是,日食在Quantity.java
的{{1}}中抱怨。将鼠标悬停在... permits QuantityImpl
上时,可以阅读:
QuantityImpl
即使编译了,这是有效的投诉还是日食中的错误?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。