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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1504403005: Add missing compile-time errors for async/await. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix after rebase Created 5 years 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
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 library dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show 8 import '../common/names.dart' show
9 Selectors; 9 Selectors;
10 import '../common/resolution.dart' show 10 import '../common/resolution.dart' show
(...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after
3680 node, 3680 node,
3681 MessageKind.RETURN_IN_GENERATOR, 3681 MessageKind.RETURN_IN_GENERATOR,
3682 {'modifier': currentAsyncMarker}); 3682 {'modifier': currentAsyncMarker});
3683 } 3683 }
3684 } 3684 }
3685 visit(node.expression); 3685 visit(node.expression);
3686 return const NoneResult(); 3686 return const NoneResult();
3687 } 3687 }
3688 3688
3689 ResolutionResult visitYield(Yield node) { 3689 ResolutionResult visitYield(Yield node) {
3690 coreClasses.streamClass.ensureResolved(resolution); 3690 if (!currentAsyncMarker.isYielding) {
3691 coreClasses.iterableClass.ensureResolved(resolution); 3691 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD);
3692 }
3693 if (currentAsyncMarker.isAsync) {
3694 coreClasses.streamClass.ensureResolved(resolution);
3695 } else {
3696 coreClasses.iterableClass.ensureResolved(resolution);
3697 }
3692 visit(node.expression); 3698 visit(node.expression);
3693 return const NoneResult(); 3699 return const NoneResult();
3694 } 3700 }
3695 3701
3696 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) { 3702 ResolutionResult visitRedirectingFactoryBody(RedirectingFactoryBody node) {
3697 if (!enclosingElement.isFactoryConstructor) { 3703 if (!enclosingElement.isFactoryConstructor) {
3698 reporter.reportErrorMessage( 3704 reporter.reportErrorMessage(
3699 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); 3705 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY);
3700 reporter.reportHintMessage( 3706 reporter.reportHintMessage(
3701 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD); 3707 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
3818 return const NoneResult(); 3824 return const NoneResult();
3819 } 3825 }
3820 3826
3821 ResolutionResult visitThrow(Throw node) { 3827 ResolutionResult visitThrow(Throw node) {
3822 registry.registerFeature(Feature.THROW_EXPRESSION); 3828 registry.registerFeature(Feature.THROW_EXPRESSION);
3823 visit(node.expression); 3829 visit(node.expression);
3824 return const NoneResult(); 3830 return const NoneResult();
3825 } 3831 }
3826 3832
3827 ResolutionResult visitAwait(Await node) { 3833 ResolutionResult visitAwait(Await node) {
3834 if (!currentAsyncMarker.isAsync) {
3835 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT);
3836 }
3828 coreClasses.futureClass.ensureResolved(resolution); 3837 coreClasses.futureClass.ensureResolved(resolution);
3829 visit(node.expression); 3838 visit(node.expression);
3830 return const NoneResult(); 3839 return const NoneResult();
3831 } 3840 }
3832 3841
3833 ResolutionResult visitVariableDefinitions(VariableDefinitions node) { 3842 ResolutionResult visitVariableDefinitions(VariableDefinitions node) {
3834 DartType type; 3843 DartType type;
3835 if (node.type != null) { 3844 if (node.type != null) {
3836 type = resolveTypeAnnotation(node.type); 3845 type = resolveTypeAnnotation(node.type);
3837 } else { 3846 } else {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 } 4352 }
4344 registry.registerTargetOf(node, target); 4353 registry.registerTargetOf(node, target);
4345 return const NoneResult(); 4354 return const NoneResult();
4346 } 4355 }
4347 4356
4348 registerImplicitInvocation(Selector selector) { 4357 registerImplicitInvocation(Selector selector) {
4349 registry.registerDynamicUse(new DynamicUse(selector, null)); 4358 registry.registerDynamicUse(new DynamicUse(selector, null));
4350 } 4359 }
4351 4360
4352 ResolutionResult visitAsyncForIn(AsyncForIn node) { 4361 ResolutionResult visitAsyncForIn(AsyncForIn node) {
4362 if (!currentAsyncMarker.isAsync) {
4363 reporter.reportErrorMessage(
4364 node.awaitToken, MessageKind.INVALID_AWAIT_FOR_IN);
4365 }
4353 registry.registerFeature(Feature.ASYNC_FOR_IN); 4366 registry.registerFeature(Feature.ASYNC_FOR_IN);
4354 registry.registerDynamicUse( 4367 registry.registerDynamicUse(
4355 new DynamicUse(Selectors.current, null)); 4368 new DynamicUse(Selectors.current, null));
4356 registry.registerDynamicUse( 4369 registry.registerDynamicUse(
4357 new DynamicUse(Selectors.moveNext, null)); 4370 new DynamicUse(Selectors.moveNext, null));
4358 4371
4359 visit(node.expression); 4372 visit(node.expression);
4360 4373
4361 Scope blockScope = new BlockScope(scope); 4374 Scope blockScope = new BlockScope(scope);
4362 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); 4375 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 } 4864 }
4852 return const NoneResult(); 4865 return const NoneResult();
4853 } 4866 }
4854 } 4867 }
4855 4868
4856 /// Looks up [name] in [scope] and unwraps the result. 4869 /// Looks up [name] in [scope] and unwraps the result.
4857 Element lookupInScope(DiagnosticReporter reporter, Node node, 4870 Element lookupInScope(DiagnosticReporter reporter, Node node,
4858 Scope scope, String name) { 4871 Scope scope, String name) {
4859 return Elements.unwrap(scope.lookup(name), reporter, node); 4872 return Elements.unwrap(scope.lookup(name), reporter, node);
4860 } 4873 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/parser.dart ('k') | tests/compiler/dart2js/async_await_syntax_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698