Skip to content

Commit adc59f6

Browse files
pqCommit Queue
authored and
Commit Queue
committed
quick fix for NULL_CHECK_ALWAYS_FAILS
See: #55917 Change-Id: Ic38b8a9e9717fc477394ea19bbb7173b2234d2f6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370380 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 224d19e commit adc59f6

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#
4646
# Stats:
4747
# - 42 "needsEvaluation"
48-
# - 335 "needsFix"
49-
# - 416 "hasFix"
48+
# - 334 "needsFix"
49+
# - 417 "hasFix"
5050
# - 516 "noFix"
5151

5252
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
@@ -3654,9 +3654,7 @@ WarningCode.NULL_ARGUMENT_TO_NON_NULL_TYPE:
36543654
status: noFix
36553655
since: ~2.15
36563656
WarningCode.NULL_CHECK_ALWAYS_FAILS:
3657-
status: needsFix
3658-
notes: |-
3659-
Remove the null check.
3657+
status: hasFix
36603658
WarningCode.OVERRIDE_ON_NON_OVERRIDING_FIELD:
36613659
status: hasFix
36623660
WarningCode.OVERRIDE_ON_NON_OVERRIDING_GETTER:

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
15881588
WarningCode.NON_CONST_CALL_TO_LITERAL_CONSTRUCTOR_USING_NEW: [
15891589
ReplaceNewWithConst.new,
15901590
],
1591+
WarningCode.NULL_CHECK_ALWAYS_FAILS: [
1592+
RemoveNonNullAssertion.new,
1593+
],
15911594
WarningCode.NULLABLE_TYPE_IN_CATCH_CLAUSE: [
15921595
RemoveQuestionMark.new,
15931596
],

pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ void f() {
8888
print(x);
8989
print(y);
9090
}
91+
''');
92+
}
93+
94+
Future<void> test_nullCheckAlwaysFails() async {
95+
await resolveTestCode('''
96+
void f() {
97+
null!;
98+
}
99+
''');
100+
await assertHasFix('''
101+
void f() {
102+
null;
103+
}
91104
''');
92105
}
93106
}

0 commit comments

Comments
 (0)