Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1545)

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 895673005: Add static type checking of "yield*" statements to analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix tests. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index c16cb353a1099bdb2880e61e5548cae5b3ac4ee5..c12fb052d288c7a3c9b0bb8ab4281206f1cdd478 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -1096,7 +1096,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitYieldStatement(YieldStatement node) {
if (_inGenerator) {
- _checkForYieldOfInvalidType(node.expression);
+ _checkForYieldOfInvalidType(node.expression, node.star != null);
} else {
CompileTimeErrorCode errorCode;
if (node.star != null) {
@@ -5718,7 +5718,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
*
* This method should only be called in generator functions.
*/
- bool _checkForYieldOfInvalidType(Expression yieldExpression) {
+ bool _checkForYieldOfInvalidType(Expression yieldExpression,
+ bool isYieldEach) {
assert(_inGenerator);
if (_enclosingFunction == null) {
return false;
@@ -5726,7 +5727,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
DartType declaredReturnType = _enclosingFunction.returnType;
DartType staticYieldedType = getStaticType(yieldExpression);
DartType impliedReturnType;
- if (_enclosingFunction.isAsynchronous) {
+ if (isYieldEach) {
+ impliedReturnType = staticYieldedType;
+ } else if (_enclosingFunction.isAsynchronous) {
impliedReturnType =
_typeProvider.streamType.substitute4(<DartType>[staticYieldedType]);
} else {
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698