From a589ad26776cdcc6ed940def15e7591b6e7e67ba Mon Sep 17 00:00:00 2001
From: Srikanth Sankaran <131454720+srikanth-sankaran@users.noreply.github.com>
Date: Tue, 26 Nov 2024 14:19:10 +0530
Subject: [PATCH] Enhanced switch v2.0 - Part I (#3310)
* Reimplement resolution, analysis and bookkeeping involved with `CaseStatement` and resolution of `SwitchStatement` for a streamlined and cleaner implementation resulting in readily obvious control flow and minimization of state.
* Report non-constant label expressions during resolution rather than waiting for flow analysis phase.
* Change how duplicate label expressions are reported. Don't blame the whole case, just the duplicate expression; Don't blame the original, just the duplicate.
* Represent qualified enumerators with qualified names internally so to avoid name clashes
* Eliminate the hack to inject synthetic `BreakStatement` in label rule switch blocks. Enhance the code generator to handle these explicitly.
* Simplify the implementation of SwitchStatement.getFallThroughState correcting various issues.
* Eliminate the unnecessary vector `SwitchStatement.constMapping` that is passed to `org.eclipse.jdt.internal.compiler.codegen.CodeStream.tableswitch` - constanMapping[i] == i always!
* Enable various tests in `PrimitiveInPatternsTest.java` that were disabled, fixing broken tests; Remove their disabled cousins from `PrimitiveInPatternsTestSH.java`
* Add a disabled regression test for #3319 (not yet understood/fixed)
* Numerous defect fixes as listed below
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3336
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3318
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3320
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3321
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3334
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3335
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3265
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3169
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3339
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3337
* Fixes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3344
---
.../.settings/.api_filters | 20 -
.../META-INF/MANIFEST.MF | 2 +-
org.eclipse.jdt.core.compiler.batch/pom.xml | 2 +-
.../jdt/internal/compiler/ClassFile.java | 51 +-
.../internal/compiler/ast/BreakStatement.java | 7 -
.../internal/compiler/ast/CaseStatement.java | 508 ++++++-------
.../jdt/internal/compiler/ast/Statement.java | 6 +-
.../compiler/ast/SwitchExpression.java | 6 -
.../compiler/ast/SwitchStatement.java | 668 +++++++-----------
.../internal/compiler/ast/TryStatement.java | 2 +-
.../internal/compiler/codegen/CodeStream.java | 5 +-
.../jdt/internal/compiler/parser/Parser.java | 3 +-
.../compiler/tool/EclipseCompiler.java | 2 +-
.../META-INF/MANIFEST.MF | 2 +-
org.eclipse.jdt.core.tests.compiler/pom.xml | 2 +-
.../compiler/regression/ConstantTest.java | 7 +-
.../tests/compiler/regression/EnumTest.java | 9 +-
.../compiler/regression/LocalEnumTest.java | 9 +-
.../regression/NullAnnotationTest.java | 85 +++
.../regression/PrimitiveInPatternsTest.java | 54 +-
.../regression/PrimitiveInPatternsTestSH.java | 259 ++-----
.../SwitchExpressionsYieldTest.java | 61 +-
.../regression/SwitchPatternTest.java | 449 ++++++++++--
.../regression/SwitchPatternTest22.java | 89 +++
.../tests/compiler/regression/SwitchTest.java | 180 ++---
.../META-INF/MANIFEST.MF | 2 +-
org.eclipse.jdt.core.tests.model/pom.xml | 2 +-
.../jdt/core/tests/RunVariousSwitchTests.java | 3 +
org.eclipse.jdt.core/.settings/.api_filters | 128 ----
org.eclipse.jdt.core/META-INF/MANIFEST.MF | 2 +-
org.eclipse.jdt.core/pom.xml | 2 +-
31 files changed, 1236 insertions(+), 1391 deletions(-)
diff --git a/org.eclipse.jdt.core.compiler.batch/.settings/.api_filters b/org.eclipse.jdt.core.compiler.batch/.settings/.api_filters
index 4fd6546f2e4..46f5be97c95 100644
--- a/org.eclipse.jdt.core.compiler.batch/.settings/.api_filters
+++ b/org.eclipse.jdt.core.compiler.batch/.settings/.api_filters
@@ -8,24 +8,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF
index 6c4cd007789..53cc25974bc 100644
--- a/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Main-Class: org.eclipse.jdt.internal.compiler.batch.Main
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Compiler for Java(TM)
Bundle-SymbolicName: org.eclipse.jdt.core.compiler.batch
-Bundle-Version: 3.40.0.qualifier
+Bundle-Version: 3.40.100.qualifier
Bundle-ClassPath: .
Bundle-Vendor: Eclipse.org
Automatic-Module-Name: org.eclipse.jdt.core.compiler.batch
diff --git a/org.eclipse.jdt.core.compiler.batch/pom.xml b/org.eclipse.jdt.core.compiler.batch/pom.xml
index 3b01ae0fe0a..fa9902c1ee5 100644
--- a/org.eclipse.jdt.core.compiler.batch/pom.xml
+++ b/org.eclipse.jdt.core.compiler.batch/pom.xml
@@ -17,7 +17,7 @@
4.35.0-SNAPSHOT
org.eclipse.jdt.core.compiler.batch
- 3.40.0-SNAPSHOT
+ 3.40.100-SNAPSHOT
eclipse-plugin
diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ClassFile.java
index 354576a4d49..97839ed39d5 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -48,7 +48,7 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.ast.CaseStatement.ResolvedCase;
+import org.eclipse.jdt.internal.compiler.ast.CaseStatement.LabelExpression;
import org.eclipse.jdt.internal.compiler.ast.SwitchStatement.SingletonBootstrap;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.codegen.*;
@@ -3613,8 +3613,8 @@ private int generateBootstrapMethods(List