redhat-developer / redhat-developer/vscode-java

Build/compilation issue with wildcard types

オープン
#4,059 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

compile upstream
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。