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

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

Issue 821593004: Create erroneous element when resolution of initializer fails. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tests passing locally. 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 unified diff | Download patch | Annotate | Revision Log
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 assert(invariant(target, targetType != null, 736 assert(invariant(target, targetType != null,
737 message: 'Redirection target type has not been computed for ' 737 message: 'Redirection target type has not been computed for '
738 '$target')); 738 '$target'));
739 target = target.internalEffectiveTarget; 739 target = target.internalEffectiveTarget;
740 break; 740 break;
741 } 741 }
742 742
743 Element nextTarget = target.immediateRedirectionTarget; 743 Element nextTarget = target.immediateRedirectionTarget;
744 if (seen.contains(nextTarget)) { 744 if (seen.contains(nextTarget)) {
745 error(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); 745 error(node, MessageKind.CYCLIC_REDIRECTING_FACTORY);
746 // TODO(ahe): Don't throw, recover from error. 746 return;
747 throw new CompilerCancelledException(null);
748 break;
749 } 747 }
750 seen.add(target); 748 seen.add(target);
751 target = nextTarget; 749 target = nextTarget;
752 } 750 }
753 751
754 if (targetType == null) { 752 if (targetType == null) {
755 assert(!target.isRedirectingFactory); 753 assert(!target.isRedirectingFactory);
756 targetType = target.enclosingClass.thisType; 754 targetType = target.enclosingClass.thisType;
757 } 755 }
758 756
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 void resolveFieldInitializer(FunctionElement constructor, SendSet init) { 1403 void resolveFieldInitializer(FunctionElement constructor, SendSet init) {
1406 // init is of the form [this.]field = value. 1404 // init is of the form [this.]field = value.
1407 final Node selector = init.selector; 1405 final Node selector = init.selector;
1408 final String name = selector.asIdentifier().source; 1406 final String name = selector.asIdentifier().source;
1409 // Lookup target field. 1407 // Lookup target field.
1410 Element target; 1408 Element target;
1411 if (isFieldInitializer(init)) { 1409 if (isFieldInitializer(init)) {
1412 target = constructor.enclosingClass.lookupLocalMember(name); 1410 target = constructor.enclosingClass.lookupLocalMember(name);
1413 if (target == null) { 1411 if (target == null) {
1414 error(selector, MessageKind.CANNOT_RESOLVE, {'name': name}); 1412 error(selector, MessageKind.CANNOT_RESOLVE, {'name': name});
1415 // TODO(ahe): Don't throw, recover from error. 1413 target = new ErroneousFieldElementX(
1416 throw new CompilerCancelledException(null); 1414 selector.asIdentifier(), constructor.enclosingClass);
1417 } else if (target.kind != ElementKind.FIELD) { 1415 } else if (target.kind != ElementKind.FIELD) {
1418 error(selector, MessageKind.NOT_A_FIELD, {'fieldName': name}); 1416 error(selector, MessageKind.NOT_A_FIELD, {'fieldName': name});
1419 // TODO(ahe): Don't throw, recover from error. 1417 target = new ErroneousFieldElementX(
1420 throw new CompilerCancelledException(null); 1418 selector.asIdentifier(), constructor.enclosingClass);
1421 } else if (!target.isInstanceMember) { 1419 } else if (!target.isInstanceMember) {
1422 error(selector, MessageKind.INIT_STATIC_FIELD, {'fieldName': name}); 1420 error(selector, MessageKind.INIT_STATIC_FIELD, {'fieldName': name});
1423 } 1421 }
1424 } else { 1422 } else {
1425 error(init, MessageKind.INVALID_RECEIVER_IN_INITIALIZER); 1423 error(init, MessageKind.INVALID_RECEIVER_IN_INITIALIZER);
1426 } 1424 }
1427 registry.useElement(init, target); 1425 registry.useElement(init, target);
1428 registry.registerStaticUse(target); 1426 registry.registerStaticUse(target);
1429 checkForDuplicateInitializers(target, init); 1427 checkForDuplicateInitializers(target, init);
1430 // Resolve initializing value. 1428 // Resolve initializing value.
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 MessageKind kind, 2233 MessageKind kind,
2236 [Map arguments = const {}]) { 2234 [Map arguments = const {}]) {
2237 compiler.reportWarning(node, kind, arguments); 2235 compiler.reportWarning(node, kind, arguments);
2238 return new ErroneousElementX(kind, arguments, name, enclosingElement); 2236 return new ErroneousElementX(kind, arguments, name, enclosingElement);
2239 } 2237 }
2240 2238
2241 ResolutionResult visitIdentifier(Identifier node) { 2239 ResolutionResult visitIdentifier(Identifier node) {
2242 if (node.isThis()) { 2240 if (node.isThis()) {
2243 if (!inInstanceContext) { 2241 if (!inInstanceContext) {
2244 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); 2242 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node});
2245 // TODO(ahe): Don't throw, recover from error.
2246 throw new CompilerCancelledException(null);
2247 } 2243 }
2248 return null; 2244 return null;
2249 } else if (node.isSuper()) { 2245 } else if (node.isSuper()) {
2250 if (!inInstanceContext) { 2246 if (!inInstanceContext) {
2251 error(node, MessageKind.NO_SUPER_IN_STATIC); 2247 error(node, MessageKind.NO_SUPER_IN_STATIC);
2252 // TODO(ahe): Don't throw, recover from error. 2248 // TODO(ahe): Don't throw, recover from error.
2253 throw new CompilerCancelledException(null); 2249 throw new CompilerCancelledException(null);
2254 } 2250 }
2255 if ((ElementCategory.SUPER & allowedCategory) == 0) { 2251 if ((ElementCategory.SUPER & allowedCategory) == 0) {
2256 error(node, MessageKind.INVALID_USE_OF_SUPER); 2252 error(node, MessageKind.INVALID_USE_OF_SUPER);
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
5012 } 5008 }
5013 5009
5014 /// The result for the resolution of the `assert` method. 5010 /// The result for the resolution of the `assert` method.
5015 class AssertResult implements ResolutionResult { 5011 class AssertResult implements ResolutionResult {
5016 const AssertResult(); 5012 const AssertResult();
5017 5013
5018 Element get element => null; 5014 Element get element => null;
5019 5015
5020 String toString() => 'AssertResult()'; 5016 String toString() => 'AssertResult()';
5021 } 5017 }
OLDNEW
« no previous file with comments | « dart/pkg/compiler/lib/src/enqueue.dart ('k') | dart/pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698