Skip to content

Commit

Permalink
[Switch Expression] yield does not work with bitwise complement ~
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-sankaran committed Dec 20, 2024
1 parent fe3554b commit adf4f17
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5549,7 +5549,6 @@ int disambiguateYield() {
case TokenNameAND:
case TokenNameMULTIPLY:
case TokenNameOR:
case TokenNameTWIDDLE:
case TokenNameDIVIDE:
case TokenNameGREATER:
case TokenNameLESS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8360,4 +8360,43 @@ public static void main(String[] args) {
},
"true");
}

// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3481
// [Switch Expression] yield does not work with bitwise complement ~
public void testIssue3481() {
this.runConformTest(
new String[] {
"X.java",
"""
public class X {
int a = switch(0) {
default -> {
yield ~1;
}
};
int b = switch(0) {
default -> {
int x = 0;
yield ~x;
}
};
int c = switch (0) {
case 0 -> {
yield ~2;
}
default -> 1;
};
{
System.out.println("a = " + a + " b = " + b + " c = " + c);
}
public static void main(String [] args) {
new X();
}
}
"""
},
"a = -2 b = -1 c = -3");
}
}

0 comments on commit adf4f17

Please sign in to comment.