[java] SwitchStmtsShouldHaveDefault - also ignore record pattern
This commit is contained in:
parent
e5ff5532d4
commit
59403fc9e1
@ -1178,8 +1178,8 @@ class SomeTestClass {
|
||||
<property name="xpath">
|
||||
<value><![CDATA[
|
||||
//SwitchStatement[@DefaultCase = false() and @ExhaustiveEnumSwitch = false()]
|
||||
(: exclude type pattern tests - for these, the compiler will ensure exhaustiveness :)
|
||||
[not(*/SwitchLabel/TypePattern)]
|
||||
(: exclude pattern tests - for these, the compiler will ensure exhaustiveness :)
|
||||
[not(*/SwitchLabel/(TypePattern|RecordPattern))]
|
||||
]]></value>
|
||||
</property>
|
||||
</properties>
|
||||
|
@ -313,6 +313,22 @@ public class Example2 {
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>With Record Patterns #4813</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
record R(int i) {}
|
||||
|
||||
public class SwitchWithRecordPattern {
|
||||
public void check(R r) {
|
||||
switch(r) {
|
||||
case R(int a) -> System.out.println(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user