microsoft / microsoft/vscode-java-debug

switch exhaustiveness check not working within deconstruction pattern

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

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

ai-triaged bug compile
主要言語
TypeScript
スター
591
フォーク
429
平均マージ
1日 9時間
マージ済み PR(30日)
19

説明

Build fails on missing default case, even though switch is exhaustive.

Environment
  • Operating System: Windows 10
  • JDK version: 19
  • Visual Studio Code version: 1.73.1
  • Java extension version: 1.12.0
  • Java Debugger extension version: 0.46.0
Steps To Reproduce

make (exhaustive) switch expression with nested deconstruction pattern
build fails -> "Add default case"

Example:

package dev.redio;

import static dev.redio.Main.Activity.*;

public class Main {

    public static void main(String[] args) {
        record Pair(boolean weekend, Activity activity) {}
        var pair = new Pair(true, new Sleeping(8));
        var msg = switch (pair) {   // <- A switch expression should have a default caseJava(1073743531)
            case Pair(boolean b, Sleeping s) -> "3";
            case Pair(boolean b, Skiing s) -> "4";
            case Pair(boolean b, Coding c) -> "5";
        };
        
        System.out.println(msg);
    }

    sealed interface Activity {
        record Sleeping(int hours) implements Activity {}
        record Skiing(String resort) implements Activity {}
        record Coding() implements Activity {}
    }
    
}
Current Result

Build Error (A switch expression should have a default caseJava(1073743531))

Expected Result

Build Success(Switch is exhaustive since all nested deconstruction possibilities are covered)

Additional Informations

Compiles with pure javac without errors
Intended and correct syntax confirmed by member of development team of the feature.

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

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

はじめの一歩

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

調査の方向性

issue にあるネストされた deconstruction-pattern switch を、記載されている VS Code と Java の環境で再現し、Extension の診断結果と純粋な javac の結果を比較します。「A switch expression should have a default case」という診断がどこで生成されるかを追跡します。完了条件は、網羅的な例がその診断なしでビルドでき、実際に非網羅的な switch では引き続きその診断が報告されることです。

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

評価

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

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

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