Skip to content

Commit 2a36502

Browse files
Kevin Millikincommit-bot@chromium.org
Kevin Millikin
authored andcommitted
Squelch some false warnings for disallowed uses of void
The rules for void are changed to allow uses of void where we previously had a warning, such as the case of assignment to a variable of type void or passing as a parameter of type void. Change-Id: I1c1513b0000fa1c8eedbe2645fab503b28024fa3 Reviewed-on: https://dart-review.googlesource.com/70265 Reviewed-by: Daniel Hillerström <[email protected]> Reviewed-by: Aske Simon Christensen <[email protected]> Commit-Queue: Kevin Millikin <[email protected]>
1 parent 244c9be commit 2a36502

File tree

6 files changed

+217
-267
lines changed

6 files changed

+217
-267
lines changed

pkg/analyzer/test/generated/static_warning_code_kernel_test.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -576,20 +576,4 @@ class StaticWarningCodeTest_Kernel extends StaticWarningCodeTest_Driver {
576576
test_undefinedIdentifier_function() async {
577577
return super.test_undefinedIdentifier_function();
578578
}
579-
580-
@override
581-
@failingTest
582-
test_useOfVoidResult_await() async {
583-
return super.test_useOfVoidResult_await();
584-
}
585-
586-
@override
587-
test_useOfVoidResult_inForLoop_ok() async {
588-
return super.test_useOfVoidResult_inForLoop_ok();
589-
}
590-
591-
@override
592-
test_useOfVoidResult_variableDeclaration_method_ok() async {
593-
return super.test_useOfVoidResult_variableDeclaration_method_ok();
594-
}
595579
}

pkg/analyzer/test/generated/static_warning_code_test.dart

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,11 +1743,7 @@ void main() {
17431743
void f(void x) {}
17441744
''');
17451745
await computeAnalysisResult(source);
1746-
if (useCFE) {
1747-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
1748-
} else {
1749-
assertNoErrors(source);
1750-
}
1746+
assertNoErrors(source);
17511747
}
17521748

17531749
test_generalizedVoid_assignToVoid_notStrong_error() async {
@@ -2088,11 +2084,7 @@ void main() {
20882084
}
20892085
''');
20902086
await computeAnalysisResult(source);
2091-
if (useCFE) {
2092-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
2093-
} else {
2094-
assertNoErrors(source);
2095-
}
2087+
assertNoErrors(source);
20962088
}
20972089

20982090
test_generalizedVoid_useOfVoidInMapLiteralKeyError() async {
@@ -2114,11 +2106,7 @@ void main() {
21142106
}
21152107
''');
21162108
await computeAnalysisResult(source);
2117-
if (useCFE) {
2118-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
2119-
} else {
2120-
assertNoErrors(source);
2121-
}
2109+
assertNoErrors(source);
21222110
}
21232111

21242112
test_generalizedVoid_useOfVoidInMapLiteralValueError() async {
@@ -2140,11 +2128,7 @@ void main() {
21402128
}
21412129
''');
21422130
await computeAnalysisResult(source);
2143-
if (useCFE) {
2144-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
2145-
} else {
2146-
assertNoErrors(source);
2147-
}
2131+
assertNoErrors(source);
21482132
}
21492133

21502134
test_generalizedVoid_useOfVoidInNullOperatorLhsError() async {
@@ -2166,11 +2150,7 @@ void main() {
21662150
}
21672151
''');
21682152
await computeAnalysisResult(source);
2169-
if (useCFE) {
2170-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
2171-
} else {
2172-
assertNoErrors(source);
2173-
}
2153+
assertNoErrors(source);
21742154
}
21752155

21762156
test_generalizedVoid_useOfVoidInSpecialAssignmentError() async {
@@ -2182,7 +2162,10 @@ void main() {
21822162
''');
21832163
await computeAnalysisResult(source);
21842164
if (useCFE) {
2185-
assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
2165+
assertErrors(source, [
2166+
StaticTypeWarningCode.UNDEFINED_METHOD,
2167+
StaticWarningCode.USE_OF_VOID_RESULT
2168+
]);
21862169
} else {
21872170
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
21882171
}
@@ -2290,11 +2273,7 @@ void main() {
22902273
}
22912274
''');
22922275
await computeAnalysisResult(source);
2293-
if (useCFE) {
2294-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
2295-
} else {
2296-
assertNoErrors(source);
2297-
}
2276+
assertNoErrors(source);
22982277
}
22992278

23002279
test_importDuplicatedLibraryNamed() async {
@@ -4885,10 +4864,7 @@ class A {
48854864
}''');
48864865
await computeAnalysisResult(source);
48874866
if (useCFE) {
4888-
assertErrors(source, [
4889-
StaticWarningCode.USE_OF_VOID_RESULT,
4890-
StaticWarningCode.USE_OF_VOID_RESULT
4891-
]);
4867+
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
48924868
} else {
48934869
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
48944870
}
@@ -4906,10 +4882,7 @@ class A {
49064882
}''');
49074883
await computeAnalysisResult(source);
49084884
if (useCFE) {
4909-
assertErrors(source, [
4910-
StaticWarningCode.USE_OF_VOID_RESULT,
4911-
StaticWarningCode.USE_OF_VOID_RESULT
4912-
]);
4885+
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
49134886
} else {
49144887
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
49154888
}
@@ -4949,11 +4922,7 @@ class A {
49494922
}
49504923
}''');
49514924
await computeAnalysisResult(source);
4952-
if (useCFE) {
4953-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
4954-
} else {
4955-
assertNoErrors(source);
4956-
}
4925+
assertNoErrors(source);
49574926
verify([source]);
49584927
}
49594928

@@ -4979,11 +4948,7 @@ class A {
49794948
}
49804949
}''');
49814950
await computeAnalysisResult(source);
4982-
if (useCFE) {
4983-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
4984-
} else {
4985-
assertNoErrors(source);
4986-
}
4951+
assertNoErrors(source);
49874952
verify([source]);
49884953
}
49894954

@@ -5025,11 +4990,7 @@ class A {
50254990
}
50264991
}''');
50274992
await computeAnalysisResult(source);
5028-
if (useCFE) {
5029-
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
5030-
} else {
5031-
assertNoErrors(source);
5032-
}
4993+
assertNoErrors(source);
50334994
verify([source]);
50344995
}
50354996

0 commit comments

Comments
 (0)