@@ -804,6 +804,12 @@ module Expressions {
804
804
private class SwitchCaseExprTree extends PostOrderTree , CaseTree , SwitchCaseExpr {
805
805
final override predicate first ( ControlFlowElement first ) { first ( this .getPattern ( ) , first ) }
806
806
807
+ pragma [ noinline]
808
+ private predicate lastNoMatch ( ControlFlowElement last , ConditionalCompletion cc ) {
809
+ last ( [ this .getPattern ( ) , this .getCondition ( ) ] , last , cc ) and
810
+ ( cc .( MatchingCompletion ) .isNonMatch ( ) or cc instanceof FalseCompletion )
811
+ }
812
+
807
813
final override predicate last ( ControlFlowElement last , Completion c ) {
808
814
PostOrderTree .super .last ( last , c )
809
815
or
@@ -812,8 +818,7 @@ module Expressions {
812
818
this = se .getCase ( i ) and
813
819
not this .matchesAll ( ) and
814
820
not exists ( se .getCase ( i + 1 ) ) and
815
- last ( [ this .getPattern ( ) , this .getCondition ( ) ] , last , cc ) and
816
- ( cc .( MatchingCompletion ) .isNonMatch ( ) or cc instanceof FalseCompletion ) and
821
+ this .lastNoMatch ( last , cc ) and
817
822
c =
818
823
any ( NestedCompletion nc |
819
824
nc .getNestLevel ( ) = 0 and
@@ -1372,11 +1377,16 @@ module Statements {
1372
1377
or
1373
1378
// If the `finally` block completes normally, it inherits any non-normal
1374
1379
// completion that was current before the `finally` block was entered
1375
- c =
1376
- any ( NestedCompletion nc |
1377
- this .lastFinally ( last , nc .getAnInnerCompatibleCompletion ( ) , nc .getOuterCompletion ( ) ,
1378
- nc .getNestLevel ( ) )
1379
- )
1380
+ exists ( int nestLevel |
1381
+ c =
1382
+ any ( NestedCompletion nc |
1383
+ this .lastFinally ( last , nc .getAnInnerCompatibleCompletion ( ) , nc .getOuterCompletion ( ) ,
1384
+ nestLevel ) and
1385
+ // unbind
1386
+ nc .getNestLevel ( ) >= nestLevel and
1387
+ nc .getNestLevel ( ) <= nestLevel
1388
+ )
1389
+ )
1380
1390
}
1381
1391
1382
1392
/**
0 commit comments