8312984: javac may crash on a record pattern with too few components
Reviewed-by: vromero
This commit is contained in:
parent
3212b64f8e
commit
c386091734
@ -3480,7 +3480,9 @@ public class Flow {
|
||||
for (List<JCPattern> it = record.nested;
|
||||
it.nonEmpty();
|
||||
it = it.tail, i++) {
|
||||
nestedDescriptions[i] = makePatternDescription(types.erasure(componentTypes[i]), it.head);
|
||||
Type componentType = i < componentTypes.length ? componentTypes[i]
|
||||
: syms.errType;
|
||||
nestedDescriptions[i] = makePatternDescription(types.erasure(componentType), it.head);
|
||||
}
|
||||
return new RecordPattern(record.type, componentTypes, nestedDescriptions);
|
||||
} else if (pattern instanceof JCAnyPattern) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
PatternErrorRecovery.java:12:18: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.pattern.switch), 20, 21
|
||||
PatternErrorRecovery.java:17:19: compiler.err.feature.not.supported.in.source.plural: (compiler.misc.feature.deconstruction.patterns), 20, 21
|
||||
PatternErrorRecovery.java:17:27: compiler.err.illegal.start.of.type
|
||||
PatternErrorRecovery.java:11:18: compiler.err.pattern.expected
|
||||
2 errors
|
||||
4 errors
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8268320
|
||||
* @bug 8268320 8312984
|
||||
* @summary Verify user-friendly errors are reported for ill-formed pattern.
|
||||
* @compile/fail/ref=PatternErrorRecovery.out -XDrawDiagnostics -XDshould-stop.at=FLOW PatternErrorRecovery.java
|
||||
* @compile/fail/ref=PatternErrorRecovery.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDdev PatternErrorRecovery.java
|
||||
* @compile/fail/ref=PatternErrorRecovery-old.out --release 20 -XDrawDiagnostics -XDshould-stop.at=FLOW PatternErrorRecovery.java
|
||||
*/
|
||||
public class PatternErrorRecovery {
|
||||
@ -12,4 +12,12 @@ public class PatternErrorRecovery {
|
||||
case Object obj: break;
|
||||
}
|
||||
}
|
||||
int errorRecoveryNoPattern2(Object o) {
|
||||
return switch(o) {
|
||||
case R(var v, ) -> 1;
|
||||
default -> -1;
|
||||
};
|
||||
}
|
||||
|
||||
record R(String x) {}
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
PatternErrorRecovery.java:17:27: compiler.err.illegal.start.of.type
|
||||
PatternErrorRecovery.java:11:18: compiler.err.pattern.expected
|
||||
1 error
|
||||
PatternErrorRecovery.java:17:18: compiler.err.incorrect.number.of.nested.patterns: java.lang.String, java.lang.String,<any>
|
||||
3 errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user