Skip to content

Commit 294b058

Browse files
fshcheglovCommit Queue
authored andcommitted
Implement a visitor method for DotShorthandPropertyAccess to ExitDetector.
Change-Id: I98a3ce4126d2ca7e7743ba788ec1dc9b580b54a2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457781 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 6d34796 commit 294b058

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-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
@@ -186,6 +186,11 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
186186
return _nodeExits(node.argumentList);
187187
}
188188

189+
@override
190+
bool visitDotShorthandPropertyAccess(DotShorthandPropertyAccess node) {
191+
return _elementExits(node.propertyName.element);
192+
}
193+
189194
@override
190195
bool visitEmptyStatement(EmptyStatement node) => false;
191196

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,28 @@ void f() {
10271027
''', 0);
10281028
}
10291029

1030+
test_dotShorthandPropertyAccess_getterReturnsNever() async {
1031+
await _assertNthStatementExits(r'''
1032+
class C {
1033+
static Never get foo => throw 42;
1034+
}
1035+
void f() {
1036+
C _ = .foo;
1037+
}
1038+
''', 0);
1039+
}
1040+
1041+
test_dotShorthandPropertyAccess_noExit() async {
1042+
await _assertNthStatementDoesNotExit(r'''
1043+
class C {
1044+
static C get foo => C();
1045+
}
1046+
void f() {
1047+
C _ = .foo;
1048+
}
1049+
''', 0);
1050+
}
1051+
10301052
test_forStatement_implicitTrue_breakWithLabel() async {
10311053
await _assertNthStatementDoesNotExit(r'''
10321054
void f() {

0 commit comments

Comments
 (0)