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

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

Issue 2619243002: Make .enclosingClass always return the declaration (Closed)
Patch Set: Add comment. Created 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.constructors; 5 library dart2js.resolution.constructors;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution; 8 import '../common/resolution.dart' show Resolution;
9 import '../constants/constructors.dart' 9 import '../constants/constructors.dart'
10 show 10 show
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 void resolveFieldInitializer(SendSet init) { 93 void resolveFieldInitializer(SendSet init) {
94 // init is of the form [this.]field = value. 94 // init is of the form [this.]field = value.
95 final Node selector = init.selector; 95 final Node selector = init.selector;
96 final String name = selector.asIdentifier().source; 96 final String name = selector.asIdentifier().source;
97 // Lookup target field. 97 // Lookup target field.
98 Element target; 98 Element target;
99 FieldElement field; 99 FieldElement field;
100 if (isFieldInitializer(init)) { 100 if (isFieldInitializer(init)) {
101 target = constructor.enclosingClass.lookupLocalMember(name); 101 // Use [enclosingElement] ensure lookup in patch class when necessary.
Siggi Cherem (dart-lang) 2017/01/11 19:24:02 ditto
Johnni Winther 2017/01/12 09:56:56 Done.
102 ClassElement cls = constructor.enclosingElement;
103 target = cls.lookupLocalMember(name);
102 if (target == null) { 104 if (target == null) {
103 reporter.reportErrorMessage( 105 reporter.reportErrorMessage(
104 selector, MessageKind.CANNOT_RESOLVE, {'name': name}); 106 selector, MessageKind.CANNOT_RESOLVE, {'name': name});
105 target = new ErroneousFieldElementX( 107 target = new ErroneousFieldElementX(
106 selector.asIdentifier(), constructor.enclosingClass); 108 selector.asIdentifier(), constructor.enclosingClass);
107 } else if (target.kind != ElementKind.FIELD) { 109 } else if (target.kind != ElementKind.FIELD) {
108 reporter.reportErrorMessage( 110 reporter.reportErrorMessage(
109 selector, MessageKind.NOT_A_FIELD, {'fieldName': name}); 111 selector, MessageKind.NOT_A_FIELD, {'fieldName': name});
110 target = new ErroneousFieldElementX( 112 target = new ErroneousFieldElementX(
111 selector.asIdentifier(), constructor.enclosingClass); 113 selector.asIdentifier(), constructor.enclosingClass);
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 // constructors. 884 // constructors.
883 return null; 885 return null;
884 } 886 }
885 // TODO(johnniwinther): Use [Name] for lookup. 887 // TODO(johnniwinther): Use [Name] for lookup.
886 ConstructorElement constructor = cls.lookupConstructor(constructorName); 888 ConstructorElement constructor = cls.lookupConstructor(constructorName);
887 if (constructor != null) { 889 if (constructor != null) {
888 constructor = constructor.declaration; 890 constructor = constructor.declaration;
889 } 891 }
890 return constructor; 892 return constructor;
891 } 893 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698