mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8348928: Check for case label validity are misbehaving when binding patterns with unnamed bindings are present
Reviewed-by: asotona, abimpoudis, vromero
This commit is contained in:
parent
188c236071
commit
7bfbb9a515
@ -4777,7 +4777,7 @@ public class Check {
|
||||
new TreeScanner() {
|
||||
@Override
|
||||
public void visitBindingPattern(JCBindingPattern tree) {
|
||||
bindings[0] = !tree.var.sym.isUnnamedVariable();
|
||||
bindings[0] |= !tree.var.sym.isUnnamedVariable();
|
||||
super.visitBindingPattern(tree);
|
||||
}
|
||||
}.scan(p);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8262891 8269146 8269113
|
||||
* @bug 8262891 8269146 8269113 8348928
|
||||
* @summary Verify errors related to pattern switches.
|
||||
* @compile/fail/ref=SwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchErrors.java
|
||||
*/
|
||||
@ -307,4 +307,22 @@ public class SwitchErrors {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void testPatternWithoutBindingCantOverridePatternWithBinding8348928a(Object o) {
|
||||
record R(int i, String s) {}
|
||||
switch (o) {
|
||||
case Integer _, R(int x, String _) -> {}
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
||||
void testPatternWithoutBindingCantOverridePatternWithBinding8348928b(Object o) {
|
||||
record R(int i, String s) {}
|
||||
switch (o) {
|
||||
case Integer _:
|
||||
case R(int x, String _):
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +57,8 @@ SwitchErrors.java:276:49: compiler.err.cant.resolve.location.args: kindname.meth
|
||||
SwitchErrors.java:278:55: compiler.err.cant.resolve.location.args: kindname.method, length, , , (compiler.misc.location: kindname.class, java.lang.Object, null)
|
||||
SwitchErrors.java:284:26: compiler.err.pattern.type.cannot.infer
|
||||
SwitchErrors.java:299:21: compiler.err.invalid.case.label.combination
|
||||
SwitchErrors.java:314:29: compiler.err.flows.through.from.pattern
|
||||
SwitchErrors.java:323:18: compiler.err.flows.through.to.pattern
|
||||
SwitchErrors.java:10:9: compiler.err.not.exhaustive.statement
|
||||
SwitchErrors.java:16:9: compiler.err.not.exhaustive.statement
|
||||
SwitchErrors.java:22:9: compiler.err.not.exhaustive.statement
|
||||
@ -69,4 +71,4 @@ SwitchErrors.java:98:9: compiler.err.not.exhaustive.statement
|
||||
SwitchErrors.java:105:9: compiler.err.not.exhaustive.statement
|
||||
SwitchErrors.java:153:9: compiler.err.not.exhaustive.statement
|
||||
SwitchErrors.java:226:9: compiler.err.not.exhaustive.statement
|
||||
71 errors
|
||||
73 errors
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user