2022-05-25 11:56:24 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
|
|
|
* @summary Verify errors related to var patterns
|
2022-11-17 00:49:53 +00:00
|
|
|
* @compile/fail/ref=VarErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDdev VarErrors.java
|
2022-05-25 11:56:24 +00:00
|
|
|
*/
|
2023-05-22 04:24:06 +00:00
|
|
|
|
2022-05-25 11:56:24 +00:00
|
|
|
public class VarErrors {
|
|
|
|
void testIf(CharSequence cs) {
|
|
|
|
if (cs instanceof var v) {}
|
|
|
|
}
|
|
|
|
void testSwitchStatement(CharSequence cs) {
|
|
|
|
switch (cs) {
|
|
|
|
case var v -> {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void testSwitchExpression(CharSequence cs) {
|
|
|
|
int i = switch (cs) {
|
|
|
|
case var v -> 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|