java - 在 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
但是,日食在抱怨... permits QuantityImpl
。当悬停在QuantityImpl
一个可以阅读:
Permitted type QuantityImpl does not declare Quantity<T> as direct super interface
即使它编译,这是一个有效的投诉还是 eclipse 中的错误?
解决方案
推荐阅读
- spring - Angular - 为什么表单中的数据不会传递给 component.ts
- javascript - 试图将对象作为json文件从spring数据下载到angular 4
- reporting-services - 在 Microsoft Dynamics AX 2012 中部署 SSRS 报告时出错
- c++ - 如何在具有不同循环的行和列的向量向量中使用 find_if
- c# - MVVM Light SimpleIoc Unregister 实例失败
- cntk - CNTK 2.5.1 Function::Load 溢出未处理的异常“未找到模块”
- wordpress - 如何重新链接“登录以回复”。关联
- javascript - 触发输入键时更改按钮样式
- react-native - `react-native init app` 在 React-Native 0.56 中不起作用
- python - 将图像分割成辐条并计算每个辐条中黑色像素的数量