Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ int test() {
);
}

void test_does_not_report_if_return_is_cached_and_used_after_return_nested_block() async {
void test_does_not_report_if_cached_and_used_after_nested_block() async {
await assertNoDiagnostics(r'''
int test(bool b) {
final a = 3;
Expand All @@ -224,5 +224,33 @@ int test(bool b) {
}
''');
}

void test_does_not_report_if_type_promoted() async {
await assertNoDiagnostics(r'''
class Test {
final Map<String, Object> _map = {};

T get<T>(String key) {
final value = _map[key];
if (value is T) {
Comment thread
solid-illiaaihistov marked this conversation as resolved.
// local variable is promoted to T
return value;
}

throw Exception('value is not of type $T');
}
}
''');
}

void test_does_not_report_if_used_in_other_return_statement() async {
await assertNoDiagnostics(r'''
String test(bool someCondition) {
final a = 'test';
if (someCondition) return a;

return 'something $a';
}
''');
}
}
Loading