File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -2445,10 +2445,10 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
24452445 flow.tryCatchStatement_bodyBegin ();
24462446 }
24472447 body.accept (this );
2448+ nullSafetyDeadCodeVerifier.flowEnd (node.body);
2449+ nullSafetyDeadCodeVerifier.tryStatementEnter (node);
24482450 if (catchClauses.isNotEmpty) {
24492451 flow.tryCatchStatement_bodyEnd (body);
2450- nullSafetyDeadCodeVerifier.flowEnd (node.body);
2451- nullSafetyDeadCodeVerifier.tryStatementEnter (node);
24522452
24532453 var catchLength = catchClauses.length;
24542454 for (var i = 0 ; i < catchLength; ++ i) {
@@ -2464,8 +2464,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
24642464 }
24652465
24662466 flow.tryCatchStatement_end ();
2467- nullSafetyDeadCodeVerifier.tryStatementExit (node);
24682467 }
2468+ nullSafetyDeadCodeVerifier.tryStatementExit (node);
24692469
24702470 if (finallyBlock != null ) {
24712471 flow.tryFinallyStatement_finallyBegin (
Original file line number Diff line number Diff line change @@ -140,6 +140,24 @@ int f(Foo foo) {
140140 error (HintCode .DEAD_CODE , 111 , 10 ),
141141 ]);
142142 }
143+
144+ test_try_finally () async {
145+ await assertErrorsInCode ('''
146+ main() {
147+ try {
148+ foo();
149+ print('dead');
150+ } finally {
151+ print('alive');
152+ }
153+ print('dead');
154+ }
155+ Never foo() => throw 'exception';
156+ ''' , [
157+ error (HintCode .DEAD_CODE , 32 , 14 ),
158+ error (HintCode .DEAD_CODE , 87 , 14 ),
159+ ]);
160+ }
143161}
144162
145163mixin DeadCodeTestCases on PubPackageResolutionTest {
You can’t perform that action at this time.
0 commit comments