-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record pattern matching with null
gives wrong result
#1804
Comments
I'm planning on working on this |
If you instead do: boolean res = b instanceof Box(Paper a) && a == null; It will print "res is false", since a completely different method is used to generate boolean methods when a part of an |
This example from Jay's comment also doesn't work: public class X {
record Paper(int color) {}
record Box<T>(T a) {}
public static void main(String argv[]) {
foo(null, null);
}
public static void foo(String abc, String def) {
Box<?> p = new Box<>(new Paper(0));
boolean b = false;
switch (p) {
case Box(Paper a) -> {
b = true;
break;
}
default -> {
b = false;
break;
}
}
System.out.println(b);
}
} However, it gives a VerifyError in the generated bytecode instead of the wrong result. |
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Boolean assignments are working, but switch statements aren't. Fully removes unused pattern variables from stack map frame. Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
@datho7561 - This is my plan for this ticket - I have assigned myself as a joint owner of this ticket. As mentioned in #1517 (comment) I am investigating and possibly undertaking a overhaul of code generation for patterns. If you don't mind, I would subsume this PR as a part of the larger work. Let us not rush this please. What do you say ? |
Okay. Just as a heads up, this issue is a blocker for code generation in lists of patterns in case statements: #1742 I've figured out how to get code generation working in eclipse-jdtls#9, but I'll probably need to rewrite the code after your overhaul of pattern code generation. |
Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Happy to report that this one works fine on master, I'll push a regression test |
Fixes eclipse-jdt#1804 Supercedes eclipse-jdt#1816 Signed-off-by: David Thompson <[email protected]>
Fixes eclipse-jdt#1804 Supercedes eclipse-jdt#1816 Signed-off-by: David Thompson <[email protected]>
* Fix RecordPattern generation for standalone instanceof * Fixes #1804 * Fixes #1985 Signed-off-by: David Thompson <[email protected]> Co-authored-by: Srikanth Sankaran <[email protected]>
) * Fix RecordPattern generation for standalone instanceof * Fixes eclipse-jdt#1804 * Fixes eclipse-jdt#1985 Signed-off-by: David Thompson <[email protected]> Co-authored-by: Srikanth Sankaran <[email protected]>
) * Fix RecordPattern generation for standalone instanceof * Fixes eclipse-jdt#1804 * Fixes eclipse-jdt#1985 Signed-off-by: David Thompson <[email protected]> Co-authored-by: Srikanth Sankaran <[email protected]>
) * Fix RecordPattern generation for standalone instanceof * Fixes eclipse-jdt#1804 * Fixes eclipse-jdt#1985 Signed-off-by: David Thompson <[email protected]> Co-authored-by: Srikanth Sankaran <[email protected]>
) * Fix RecordPattern generation for standalone instanceof * Fixes eclipse-jdt#1804 * Fixes eclipse-jdt#1985 Signed-off-by: David Thompson <[email protected]> Co-authored-by: Srikanth Sankaran <[email protected]>
Spotted by Jay in #1517 (comment)
Given the following code:
ECJ prints "res is true" while javac prints "res is false".
The text was updated successfully, but these errors were encountered: