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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/tree/nodes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR, 513 MessageKind.ASYNC_MODIFIER_ON_CONSTRUCTOR,
514 {'modifier': element.asyncMarker}); 514 {'modifier': element.asyncMarker});
515 } else { 515 } else {
516 if (element.isSetter) { 516 if (element.isSetter) {
517 compiler.reportError(asyncModifier, 517 compiler.reportError(asyncModifier,
518 MessageKind.ASYNC_MODIFIER_ON_SETTER, 518 MessageKind.ASYNC_MODIFIER_ON_SETTER,
519 {'modifier': element.asyncMarker}); 519 {'modifier': element.asyncMarker});
520 520
521 } 521 }
522 if (functionExpression.body.asReturn() != null && 522 if (functionExpression.body.asReturn() != null &&
523 element.asyncMarker.isYielding) { 523 element.asyncMarker.isYielding) {
524 compiler.reportError(asyncModifier, 524 compiler.reportError(asyncModifier,
525 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY, 525 MessageKind.YIELDING_MODIFIER_ON_ARROW_BODY,
526 {'modifier': element.asyncMarker}); 526 {'modifier': element.asyncMarker});
527 } 527 }
528 } 528 }
529 registry.registerAsyncMarker(element); 529 registry.registerAsyncMarker(element);
530 switch (element.asyncMarker) {
531 case AsyncMarker.ASYNC:
532 compiler.futureClass.ensureResolved(compiler);
533 break;
534 case AsyncMarker.ASYNC_STAR:
535 compiler.streamClass.ensureResolved(compiler);
536 break;
537 case AsyncMarker.SYNC_STAR:
538 compiler.iterableClass.ensureResolved(compiler);
539 break;
540 }
530 } 541 }
531 } 542 }
532 543
533 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { 544 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) {
534 assert(classElement != null); 545 assert(classElement != null);
535 while (classElement != null) { 546 while (classElement != null) {
536 if (classElement.isNative) return true; 547 if (classElement.isNative) return true;
537 classElement = classElement.superclass; 548 classElement = classElement.superclass;
538 } 549 }
539 return false; 550 return false;
(...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 } 3136 }
3126 3137
3127 visitRethrow(Rethrow node) { 3138 visitRethrow(Rethrow node) {
3128 if (!inCatchBlock) { 3139 if (!inCatchBlock) {
3129 error(node, MessageKind.THROW_WITHOUT_EXPRESSION); 3140 error(node, MessageKind.THROW_WITHOUT_EXPRESSION);
3130 } 3141 }
3131 } 3142 }
3132 3143
3133 visitReturn(Return node) { 3144 visitReturn(Return node) {
3134 Node expression = node.expression; 3145 Node expression = node.expression;
3135 if (expression != null && 3146 if (expression != null) {
3136 enclosingElement.isGenerativeConstructor) { 3147 if (enclosingElement.isGenerativeConstructor) {
3137 // It is a compile-time error if a return statement of the form 3148 // It is a compile-time error if a return statement of the form
3138 // `return e;` appears in a generative constructor. (Dart Language 3149 // `return e;` appears in a generative constructor. (Dart Language
3139 // Specification 13.12.) 3150 // Specification 13.12.)
3140 compiler.reportError(expression, 3151 compiler.reportError(expression,
3141 MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR); 3152 MessageKind.CANNOT_RETURN_FROM_CONSTRUCTOR);
3153 } else if (!node.isArrowBody && currentAsyncMarker.isYielding) {
3154 compiler.reportError(
3155 node,
3156 MessageKind.RETURN_IN_GENERATOR,
3157 {'modifier': currentAsyncMarker});
3158 }
3142 } 3159 }
3143 visit(node.expression); 3160 visit(node.expression);
3144 } 3161 }
3145 3162
3146 visitYield(Yield node) { 3163 visitYield(Yield node) {
3147 compiler.streamClass.ensureResolved(compiler); 3164 compiler.streamClass.ensureResolved(compiler);
3148 compiler.iterableClass.ensureResolved(compiler); 3165 compiler.iterableClass.ensureResolved(compiler);
3149 visit(node.expression); 3166 visit(node.expression);
3150 } 3167 }
3151 3168
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 } 5066 }
5050 5067
5051 /// The result for the resolution of the `assert` method. 5068 /// The result for the resolution of the `assert` method.
5052 class AssertResult implements ResolutionResult { 5069 class AssertResult implements ResolutionResult {
5053 const AssertResult(); 5070 const AssertResult();
5054 5071
5055 Element get element => null; 5072 Element get element => null;
5056 5073
5057 String toString() => 'AssertResult()'; 5074 String toString() => 'AssertResult()';
5058 } 5075 }
OLDNEW
« 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