Skip to content

Commit

Permalink
Eclipse can't build when error in switch
Browse files Browse the repository at this point in the history
Fixes eclipse
#2870
  • Loading branch information
srikanth-sankaran committed Sep 5, 2024
1 parent 0f92fb3 commit effeafd
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 19 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.compiler.batch/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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.39.0.qualifier
Bundle-Version: 3.39.100.qualifier
Bundle-ClassPath: .
Bundle-Vendor: Eclipse.org
Automatic-Module-Name: org.eclipse.jdt.core.compiler.batch
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.compiler.batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<version>4.34.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jdt.core.compiler.batch</artifactId>
<version>3.39.0-SNAPSHOT</version>
<version>3.39.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public TypeBinding resolveType(BlockScope scope) {
this.type.bits |= ASTNode.IgnoreRawTypeCheck;
this.resolvedType = this.type.resolveType(scope);

if (!this.resolvedType.isRecord()) {
scope.problemReporter().unexpectedTypeinRecordPattern(this.resolvedType, this.type);
if (this.resolvedType == null || !this.resolvedType.isRecord()) {
scope.problemReporter().unexpectedTypeinRecordPattern(this.type);
return this.resolvedType;
}
if (this.resolvedType.components().length != this.patterns.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12550,11 +12550,11 @@ public void unexpectedTypeinSwitchPattern(TypeBinding type, ASTNode element) {
element.sourceStart,
element.sourceEnd);
}
public void unexpectedTypeinRecordPattern(TypeBinding type, ASTNode element) {
public void unexpectedTypeinRecordPattern(ASTNode element) {
this.handle(
IProblem.UnexpectedTypeinRecordPattern,
new String[] {new String(type.readableName())},
new String[] {new String(type.shortReadableName())},
NoArgument,
NoArgument,
element.sourceStart,
element.sourceEnd);
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler;singleton:=true
Bundle-Version: 3.13.500.qualifier
Bundle-Version: 3.13.600.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.compiler,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<relativePath>../tests-pom/</relativePath>
</parent>
<artifactId>org.eclipse.jdt.core.tests.compiler</artifactId>
<version>3.13.500-SNAPSHOT</version>
<version>3.13.600-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8303,4 +8303,56 @@ public static void main(String[] args) {
},
"42");
}

// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2870
// eclipse can't build when error in switch
public void testIssue2870() {
runNegativeTest(
new String[] {
"X.java",
"""
public class X {
enum EnumError {
TEST(0);
private int value;
private EnumError(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
}
public static void main(String[] args) {
int bouh = 0;
switch(bouh) {
case EnumError.TEST.getValue() :
break;
}
}
}
"""
},
"----------\n" +
"1. ERROR in X.java (at line 19)\r\n" +
" switch(bouh) {\r\n" +
" ^^^^\n" +
"An enhanced switch statement should be exhaustive; a default label expected\n" +
"----------\n" +
"2. ERROR in X.java (at line 20)\r\n" +
" case EnumError.TEST.getValue() :\r\n" +
" ^^^^^^^^^^^^^^\n" +
"EnumError.TEST cannot be resolved to a type\n" +
"----------\n" +
"3. ERROR in X.java (at line 20)\r\n" +
" case EnumError.TEST.getValue() :\r\n" +
" ^^^^^^^^^^^^^^^^^^^^^^^\n" +
"Only record types are permitted in a record pattern\n" +
"----------\n");
}
}
16 changes: 8 additions & 8 deletions org.eclipse.jdt.core/.settings/.api_filters
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jdt.core" version="2">
<resource path="META-INF/MANIFEST.MF">
<filter id="924844039">
<message_arguments>
<message_argument value="3.39.100"/>
<message_argument value="3.39.0"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/AbstractTagElement.java" type="org.eclipse.jdt.core.dom.AbstractTagElement">
<filter id="576725006">
<message_arguments>
Expand Down Expand Up @@ -214,14 +222,6 @@
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/TypePattern.java" type="org.eclipse.jdt.core.dom.TypePattern">
<filter id="336658481">
<message_arguments>
<message_argument value="org.eclipse.jdt.core.dom.TypePattern"/>
<message_argument value="PATTERN_VARIABLE_PROPERTY2"/>
</message_arguments>
</filter>
</resource>
<resource path="dom/org/eclipse/jdt/core/dom/VariableDeclaration.java" type="org.eclipse.jdt.core.dom.VariableDeclaration">
<filter id="576778288">
<message_arguments>
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
Bundle-Version: 3.39.0.qualifier
Bundle-Version: 3.39.100.qualifier
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<version>4.34.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.39.0-SNAPSHOT</version>
<version>3.39.100-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<properties>
Expand Down

0 comments on commit effeafd

Please sign in to comment.