@@ -633,7 +633,7 @@ private void clearPendingExits(boolean inMethod) {
633
633
while (exits .nonEmpty ()) {
634
634
PendingExit exit = exits .head ;
635
635
exits = exits .tail ;
636
- Assert .check ((inMethod && (exit .tree .hasTag (RETURN ) || exit .tree .hasTag (MATCH ))) ||
636
+ Assert .check ((inMethod && (exit .tree .hasTag (RETURN ) || exit .tree .hasTag (MATCH ) || exit . tree . hasTag ( MATCHFAIL ) )) ||
637
637
log .hasErrorOn (exit .tree .pos ()));
638
638
}
639
639
}
@@ -725,6 +725,10 @@ public void visitTypeTestStatement(JCInstanceOfStatement tree) {
725
725
alive = alive .or (resolveBreaks (tree , prevPendingExits ));
726
726
}
727
727
728
+ public void visitMatchFail (JCMatchFail tree ) {
729
+ recordExit (new PendingExit (tree ));
730
+ }
731
+
728
732
public void visitForeachLoop (JCEnhancedForLoop tree ) {
729
733
visitVarDef (tree .var );
730
734
ListBuffer <PendingExit > prevPendingExits = pendingExits ;
@@ -827,6 +831,10 @@ private boolean exhausts(JCExpression selector, List<JCCase> cases) {
827
831
828
832
for (var l : c .labels ) {
829
833
if (l instanceof JCPatternCaseLabel patternLabel ) {
834
+ if (patternLabel .pat instanceof JCRecordPattern rec &&
835
+ !rec .patternDeclaration .patternFlags .contains (PatternFlags .TOTAL )) {
836
+ continue ;
837
+ }
830
838
for (Type component : components (selector .type )) {
831
839
patternSet .add (makePatternDescription (component , patternLabel .pat ));
832
840
}
@@ -1585,6 +1593,7 @@ else if ((tree.sym.flags() & (BLOCK | STATIC)) != BLOCK)
1585
1593
if (!(exit instanceof ThrownPendingExit )) {
1586
1594
Assert .check (exit .tree .hasTag (RETURN ) ||
1587
1595
exit .tree .hasTag (MATCH ) ||
1596
+ exit .tree .hasTag (MATCHFAIL ) ||
1588
1597
log .hasErrorOn (exit .tree .pos ()));
1589
1598
} else {
1590
1599
// uncaught throws will be reported later
@@ -1846,6 +1855,10 @@ public void visitMatch(JCMatch tree) {
1846
1855
recordExit (new PendingExit (tree ));
1847
1856
}
1848
1857
1858
+ public void visitMatchFail (JCMatchFail tree ) {
1859
+ recordExit (new PendingExit (tree ));
1860
+ }
1861
+
1849
1862
public void visitThrow (JCThrow tree ) {
1850
1863
scan (tree .expr );
1851
1864
Symbol sym = TreeInfo .symbol (tree .expr );
0 commit comments