Skip to content

Commit

Permalink
Blah
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran committed Apr 1, 2024
1 parent 2c4b5ca commit ab60b34
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7730,16 +7730,21 @@ private TypeBinding retrieveLocalType(int currentPC, int resolvedPosition) {
}
}
}
return null;
if (this.methodDeclaration.binding.declaringClass.isEnum() && this.methodDeclaration.binding.isConstructor()) {
return switch(resolvedPosition) {
case 0 -> this.methodDeclaration.binding.declaringClass;
case 1 -> this.classFile.referenceBinding.scope.getJavaLangString();
case 2 -> TypeBinding.INT;
default -> null;
};
}
return resolvedPosition != 0 || this.methodDeclaration.isStatic() ? null : this.methodDeclaration.binding.declaringClass;
}
private void pushTypeBinding(int resolvedPosition) {
if (!isSwitchStackTrackingActive())
return;
assert resolvedPosition < this.maxLocals;
TypeBinding type = retrieveLocalType(this.position, resolvedPosition);
if (type == null && resolvedPosition == 0 && !this.methodDeclaration.isStatic()) {
type = this.methodDeclaration.binding.declaringClass; // thisReference.resolvedType
}
assert type != null;
pushTypeBinding(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6862,4 +6862,36 @@ public static void main(String[] args) {
},
"Entry = Hello");
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2233
// [Switch-Expression] Assertion failure while compiling enum class that uses switch expression with try block
public void testIssue2233() {
if (this.complianceLevel < ClassFileConstants.JDK16)
return;
this.runConformTest(
new String[] {
"X.java",
"""
public enum X {
PARAMETER, FIELD, METHOD;
X() {
System.out.println(switch (this) {
default -> {
try {
yield 10;
} finally {
}
}
});
}
public static void main(String [] args) {
X x = PARAMETER;
System.out.println(x);
}
}
"""
},
"Entry = Hello");
}
}

0 comments on commit ab60b34

Please sign in to comment.