Skip to content

Commit 5b1be80

Browse files
scheglovCommit Queue
authored andcommitted
CQ. Fix for not-implemented exception in ExitDetector for NullAwareElement.
Saw a crash in logs: StateError: Bad state: Missing a visit method for a node of type NullAwareElementImpl at ExitDetector.visitNode (exit_detector.dart:457) at GeneralizingAstVisitor.visitCatchClause (visitor.g.dart:89) at GeneralizingAstVisitor.visitExpression (visitor.g.dart:216) at NullAwareElementImpl.accept (ast.dart:17535) at _extension#1.terminatesControl (use_build_context_synchronously.dart:1377) at AsyncStateVisitor._visitIfLike (use_build_context_synchronously.dart:857) at AsyncStateVisitor.visitIfStatement (use_build_context_synchronously.dart:426) at IfElementImpl.accept (ast.dart:12479) at AsyncStateVisitor._asynchronousIfAnyIsAsync.<fn> (use_build_context_synchronously.dart:682) Change-Id: Idf79a71b33411eba63b2a01b22d1f18b89fbeac4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456111 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent fca41fa commit 5b1be80

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/analyzer/lib/src/dart/resolver/exit_detector.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,11 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
475475
);
476476
}
477477

478+
@override
479+
bool? visitNullAwareElement(NullAwareElement node) {
480+
return _nodeExits(node.value);
481+
}
482+
478483
@override
479484
bool visitParenthesizedExpression(ParenthesizedExpression node) =>
480485
node.expression.accept(this)!;

pkg/analyzer/test/src/dart/resolver/exit_detector_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class ExitDetectorForCodeAsUiTest extends ParseBase {
108108
_assertFalse('[if (c) throw 42 else 0]');
109109
}
110110

111+
test_nullAwareElement() async {
112+
_assertFalse('[?0]');
113+
}
114+
111115
void _assertFalse(String expressionCode) {
112116
_assertHasReturn(expressionCode, false);
113117
}

0 commit comments

Comments
 (0)