@@ -1252,6 +1252,13 @@ module Internal {
12521252 not c instanceof GotoDefaultCompletion and
12531253 not c instanceof GotoCaseCompletion
12541254 or
1255+ // Last case exits with a non-match
1256+ exists ( int last |
1257+ last = max ( int i | exists ( ss .getCase ( i ) ) ) |
1258+ result = lastConstCaseNoMatch ( ss .getCase ( last ) , c ) or
1259+ result = lastTypeCaseNoMatch ( ss .getCase ( last ) , c )
1260+ )
1261+ or
12551262 // Last statement exits with any non-break completion
12561263 exists ( int last |
12571264 last = max ( int i | exists ( ss .getStmt ( i ) ) ) |
@@ -1262,8 +1269,7 @@ module Internal {
12621269 or
12631270 cfe = any ( ConstCase cc |
12641271 // Case expression exits with a non-match
1265- result = lastConstCaseExpr ( cc , c ) and
1266- c = any ( MatchingCompletion mc | not mc .isMatch ( ) )
1272+ result = lastConstCaseNoMatch ( cc , c )
12671273 or
12681274 // Case expression exits abnormally
12691275 result = lastConstCaseExpr ( cc , c ) and
@@ -1275,8 +1281,7 @@ module Internal {
12751281 or
12761282 cfe = any ( TypeCase tc |
12771283 // Type test exits with a non-match
1278- result = tc .getTypeAccess ( ) and
1279- c = any ( MatchingCompletion mc | not mc .isMatch ( ) )
1284+ result = lastTypeCaseNoMatch ( tc , c )
12801285 or
12811286 // Condition exists with a `false` completion
12821287 result = lastTypeCaseCondition ( tc , c ) and
@@ -1405,6 +1410,17 @@ module Internal {
14051410 )
14061411 }
14071412
1413+ private ControlFlowElement lastConstCaseNoMatch ( ConstCase cc , MatchingCompletion c ) {
1414+ result = lastConstCaseExpr ( cc , c ) and
1415+ not c .isMatch ( )
1416+ }
1417+
1418+ private ControlFlowElement lastTypeCaseNoMatch ( TypeCase tc , MatchingCompletion c ) {
1419+ result = tc .getTypeAccess ( ) and
1420+ not c .isMatch ( ) and
1421+ c .isValidFor ( result )
1422+ }
1423+
14081424 pragma [ noinline, nomagic]
14091425 private ControlFlowElement lastStandardElementGetNonLastChildElement ( StandardElement se , int i , Completion c ) {
14101426 result = last ( se .getNonLastChildElement ( i ) , c )
@@ -1935,7 +1951,7 @@ module Internal {
19351951 or
19361952 // Flow from last element of switch expression to first element of first statement
19371953 cfe = lastSwitchStmtCondition ( ss , c ) and
1938- c instanceof SimpleCompletion and
1954+ c instanceof NormalCompletion and
19391955 result = first ( ss .getStmt ( 0 ) )
19401956 or
19411957 // Flow from last element of non-`case` statement `i` to first element of statement `i+1`
@@ -2123,7 +2139,7 @@ module Internal {
21232139 exists ( ForeachStmt fs |
21242140 // Flow from last element of iterator expression to emptiness test
21252141 cfe = lastForeachStmtIterableExpr ( fs , c ) and
2126- c instanceof SimpleCompletion and
2142+ c instanceof NormalCompletion and
21272143 result = fs
21282144 or
21292145 // Flow from emptiness test to first element of variable declaration/loop body
0 commit comments