Analyzer: Fix missing errors during (a)sync(*) yield of void.
Change-Id: Iff1d87862b2f684c0ce36b0f07620f62f2e49a85
Reviewed-on: https://dart-review.googlesource.com/c/78323
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 60f0f91..cd43c68 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -1327,6 +1327,7 @@
}
_errorReporter.reportErrorForNode(errorCode, node);
}
+ _checkForUseOfVoidResult(node.expression);
return super.visitYieldStatement(node);
}
diff --git a/pkg/analyzer/test/generated/static_warning_code_test.dart b/pkg/analyzer/test/generated/static_warning_code_test.dart
index 1bfa2aa..c2074ea 100644
--- a/pkg/analyzer/test/generated/static_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_warning_code_test.dart
@@ -1875,6 +1875,46 @@
assertNoErrors(source);
}
+ test_generalizedVoid_yieldStarVoid_asyncStar() async {
+ Source source = addSource(r'''
+main(void x) async* {
+ yield* x;
+}
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
+ }
+
+ test_generalizedVoid_yieldStarVoid_syncStar() async {
+ Source source = addSource(r'''
+main(void x) sync* {
+ yield* x;
+}
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
+ }
+
+ test_generalizedVoid_yieldVoid_asyncStar() async {
+ Source source = addSource(r'''
+main(void x) async* {
+ yield x;
+}
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
+ }
+
+ test_generalizedVoid_yieldVoid_syncStar() async {
+ Source source = addSource(r'''
+main(void x) sync* {
+ yield x;
+}
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
+ }
+
test_importDuplicatedLibraryNamed() async {
Source source = addSource(r'''
library test;
diff --git a/tests/language_2/language_2_analyzer.status b/tests/language_2/language_2_analyzer.status
index d773970..1a7bb18 100644
--- a/tests/language_2/language_2_analyzer.status
+++ b/tests/language_2/language_2_analyzer.status
@@ -139,11 +139,7 @@
void/return_future_future_or_void_async_error1_test/none: CompileTimeError # issue #34319
void/return_future_or_future_or_void_sync_error2_test/none: CompileTimeError # issue #34319
void/return_future_or_void_sync_error4_test/none: CompileTimeError # issue #34319
-void/void_type_usage_test/async_use_in_yield: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
-void/void_type_usage_test/async_use_in_yield_star: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
void/void_type_usage_test/final_local_for_in2: MissingCompileTimeError
-void/void_type_usage_test/sync_use_in_yield: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
-void/void_type_usage_test/sync_use_in_yield_star: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
web_int_literals_test/01: MissingCompileTimeError
web_int_literals_test/02: MissingCompileTimeError
web_int_literals_test/03: MissingCompileTimeError
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index 9e738e9..4a60cb4 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -214,11 +214,7 @@
void/return_future_future_or_void_async_error1_test/none: CompileTimeError # issue #34319
void/return_future_or_future_or_void_sync_error2_test/none: CompileTimeError # issue #34319
void/return_future_or_void_sync_error4_test/none: CompileTimeError # issue #34319
-void/void_type_usage_test/async_use_in_yield: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
-void/void_type_usage_test/async_use_in_yield_star: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
void/void_type_usage_test/final_local_for_in2: MissingCompileTimeError
-void/void_type_usage_test/sync_use_in_yield: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
-void/void_type_usage_test/sync_use_in_yield_star: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/30177
[ $compiler == dartdevk ]
built_in_identifier_type_annotation_test/dynamic-funarg: RuntimeError # Issue 30450, test name contains hyphen