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

Unified Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 962603002: Typecheck return with respect to async. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated and tested. Created 5 years, 10 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/compiler/lib/src/tree/nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index a4ddda5a7082ea7e875cb864ed20c212d753e0ab..40ed27de0c4b60a5300c91a46f189696eb0f90cf 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -520,13 +520,24 @@ class ResolverTask extends CompilerTask {
}
if (functionExpression.body.asReturn() != null &&
- element.asyncMarker.isYielding) {
+ element.asyncMarker.isYielding) {
compiler.reportError(asyncModifier,
MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
{'modifier': element.asyncMarker});
}
}
registry.registerAsyncMarker(element);
+ switch (element.asyncMarker) {
+ case AsyncMarker.ASYNC:
+ compiler.futureClass.ensureResolved(compiler);
+ break;
+ case AsyncMarker.ASYNC_STAR:
+ compiler.streamClass.ensureResolved(compiler);
+ break;
+ case AsyncMarker.SYNC_STAR:
+ compiler.iterableClass.ensureResolved(compiler);
+ break;
+ }
}
}
@@ -3132,13 +3143,19 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
visitReturn(Return node) {
Node expression = node.expression;
- if (expression != null &&
- enclosingElement.isGenerativeConstructor) {
- // It is a compile-time error if a return statement of the form
- // `return e;` appears in a generative constructor. (Dart Language
- // Specification 13.12.)
- compiler.reportError(expression,
- MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR);
+ if (expression != null) {
+ if (enclosingElement.isGenerativeConstructor) {
+ // It is a compile-time error if a return statement of the form
+ // `return e;` appears in a generative constructor. (Dart Language
+ // Specification 13.12.)
+ compiler.reportError(expression,
+ MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR);
+ } else if (!node.isArrowBody && currentAsyncMarker.isYielding) {
+ compiler.reportError(
+ node,
+ MessageKind.RETURN_IN_GENERATOR,
+ {'modifier': currentAsyncMarker});
+ }
}
visit(node.expression);
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/tree/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698