redhat-developer / redhat-developer/vscode-java

Extended generic type loses more specific type when using recursive type bound (works in IntelliJ)

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

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

upstream
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

The inferred type when using recursive type bounds is missing a more specific wildcard when looking at the definition of a variable (e.g. via hovering it). This works in IntelliJ, but not in VS Code.

VS Code:

Fruit<?>

image

IntelliJ:

Fruit<? extends Fruit<?>>

image

Environment
  • Operating System: macOS Sonoma 14
  • JDK version: 21.0.2
  • Visual Studio Code version: 1.94.2
  • Java extension version: v0.29.0
Steps To Reproduce

Here is a made-up example with two classes:

Fruit.java

public class Fruit<T extends Fruit<T>> implements Comparable<T> {
    private final Integer size;

    public Fruit(Integer size) {
        this.size = size;
    }

    public Integer getSize() {
        return size;
    }

    @Override public int compareTo(T other) {
        return size.compareTo(other.getSize());     // Now getSize() is available.
    }
}

Apple.java

class Apple extends Fruit<Apple> {
    public Apple(Integer size) {
        super(size);
    }
}

Some random class/function to check:

public Fruit<? extends Fruit<?>> getFruit(Fruit<? extends Fruit<?>> someFruit) {
    // in real world code, assume some mapper/runtime check here
    // var someFruit = ...
    return new Fruit<>(1);
}

Somewhere else:

var fruit = getFruit(new Apple(1));
Current Result

Fruit<?> (in the definition window)

Expected Result

Fruit<? extends Fruit<?>> (in the definition window)

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

報告された VS Code と Java 拡張機能のセットアップを使用し、まず Fruit.java と Apple.java の例でホバーまたは定義の結果を再現します。推論された型を、期待される再帰的なワイルドカード形式と比較します。例について定義ウィンドウに Fruit\u003c? extends Fruit\u003c?\u003e\u003eFruit\u003c?\u003e ではなく表示されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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