@@ -804,6 +804,12 @@ module Expressions {
804804 private class SwitchCaseExprTree extends PostOrderTree , CaseTree , SwitchCaseExpr {
805805 final override predicate first ( ControlFlowElement first ) { first ( this .getPattern ( ) , first ) }
806806
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+
807813 final override predicate last ( ControlFlowElement last , Completion c ) {
808814 PostOrderTree .super .last ( last , c )
809815 or
@@ -812,8 +818,7 @@ module Expressions {
812818 this = se .getCase ( i ) and
813819 not this .matchesAll ( ) and
814820 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
817822 c =
818823 any ( NestedCompletion nc |
819824 nc .getNestLevel ( ) = 0 and
@@ -1372,11 +1377,16 @@ module Statements {
13721377 or
13731378 // If the `finally` block completes normally, it inherits any non-normal
13741379 // 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+ )
13801390 }
13811391
13821392 /**
0 commit comments