redhat-developer / redhat-developer/vscode-java
Build/compilation issue with wildcard types
未关闭
还没有人认领这个 Issue。
compile
upstream
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 546
- 平均合并
- 20 小时 1 分钟
- 30 天内合并 PR
- 11
描述
Following is some sample code to replicate the issue:
import java.util.List;
public class Tester {
<T extends List<? extends Entry<?, ?>>> Entry<?, ?> test(T input) {
return ConcreteEntry.from(input.get(0)); // Error here
}
public static void main(String[] args) {
Tester tester = new Tester();
System.out.println(tester.test(List.of(new ConcreteEntry<>("a", 1))));
}
}
interface Entry<K, V> {
K getKey();
V getValue();
}
class ConcreteEntry<K, V> implements Entry<K, V> {
private final K key;
private final V value;
public ConcreteEntry(K key, V value) {
this.key = key;
this.value = value;
}
public static <K, V> ConcreteEntry<K, V> from(Entry<K, V> entry) {
return new ConcreteEntry<>(entry.getKey(), entry.getValue());
}
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public String toString() {
return this.key + "=" + this.value;
}
}
The test method throws the error The method from(Entry<K,V>) in the type ConcreteEntry is not applicable for the arguments (capture#1-of ? extends Entry<?,?>) Java(67108979). The expected behaviour is correct compilation. However, enabling the "java.jdt.ls.javac.enabled" works, but is not an ideal solution.
This occurs with the latest Language Support for Java(TM) by Red Hat - v1.42.0.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 Language Support for Java v1.42.0,通过 issue 中的 Java 示例复现报告的诊断:先使用正常的编译器路径,然后启用 java.jdt.ls.javac.enabled。比较两次结果,并确认通配符类型示例在修正后的路径上可以无错误地编译。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100