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

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2663063004: Don't resolve FieldFormalParameter field if not in constructor. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 /** 4307 /**
4308 * Initialize using the given serialized information. 4308 * Initialize using the given serialized information.
4309 */ 4309 */
4310 FieldFormalParameterElementImpl.forSerialized( 4310 FieldFormalParameterElementImpl.forSerialized(
4311 UnlinkedParam unlinkedParam, ElementImpl enclosingElement) 4311 UnlinkedParam unlinkedParam, ElementImpl enclosingElement)
4312 : super.forSerialized(unlinkedParam, enclosingElement); 4312 : super.forSerialized(unlinkedParam, enclosingElement);
4313 4313
4314 @override 4314 @override
4315 FieldElement get field { 4315 FieldElement get field {
4316 if (_unlinkedParam != null && _field == null) { 4316 if (_unlinkedParam != null && _field == null) {
4317 Element enclosing = enclosingElement?.enclosingElement; 4317 Element enclosingConstructor = enclosingElement;
4318 while (enclosing != null) { 4318 if (enclosingConstructor is ConstructorElement) {
4319 if (enclosing is ClassElement) { 4319 Element enclosingClass = enclosingConstructor.enclosingElement;
4320 _field = enclosing.getField(_unlinkedParam.name); 4320 if (enclosingClass is ClassElement) {
4321 break; 4321 FieldElement field = enclosingClass.getField(_unlinkedParam.name);
4322 } else { 4322 if (field != null && !field.isSynthetic) {
4323 enclosing = enclosing.enclosingElement; 4323 _field = field;
4324 }
4324 } 4325 }
4325 } 4326 }
4326 } 4327 }
4327 return _field; 4328 return _field;
4328 } 4329 }
4329 4330
4330 void set field(FieldElement field) { 4331 void set field(FieldElement field) {
4331 _assertNotResynthesized(_unlinkedParam); 4332 _assertNotResynthesized(_unlinkedParam);
4332 _field = field; 4333 _field = field;
4333 } 4334 }
(...skipping 4304 matching lines...) Expand 10 before | Expand all | Expand 10 after
8638 8639
8639 @override 8640 @override
8640 void visitElement(Element element) { 8641 void visitElement(Element element) {
8641 int offset = element.nameOffset; 8642 int offset = element.nameOffset;
8642 if (offset != -1) { 8643 if (offset != -1) {
8643 map[offset] = element; 8644 map[offset] = element;
8644 } 8645 }
8645 super.visitElement(element); 8646 super.visitElement(element);
8646 } 8647 }
8647 } 8648 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698