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

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

Issue 1686283002: Ensure that element handles never refer to Member objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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.member; 5 library analyzer.src.dart.element.member;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/dart/element/type.dart'; 9 import 'package:analyzer/dart/element/type.dart';
10 import 'package:analyzer/src/dart/element/element.dart'; 10 import 'package:analyzer/src/dart/element/element.dart';
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 return new ConstructorMember(constructor, definingType, substitutedType); 122 return new ConstructorMember(constructor, definingType, substitutedType);
123 } 123 }
124 } 124 }
125 125
126 /** 126 /**
127 * An executable element defined in a parameterized type where the values of the 127 * An executable element defined in a parameterized type where the values of the
128 * type parameters are known. 128 * type parameters are known.
129 */ 129 */
130 abstract class ExecutableMember extends Member implements ExecutableElement { 130 abstract class ExecutableMember extends Member implements ExecutableElement {
131 @override 131 FunctionType _type;
132 final FunctionType type;
133 132
134 /** 133 /**
135 * Initialize a newly created element to represent a callable element (like a 134 * Initialize a newly created element to represent a callable element (like a
136 * method or function or property), based on the [baseElement], defined by the 135 * method or function or property), based on the [baseElement], defined by the
137 * [definingType]. If [type] is passed, it represents the full type of the 136 * [definingType]. If [type] is passed, it represents the full type of the
138 * member, and will take precedence over the [definingType]. 137 * member, and will take precedence over the [definingType].
139 */ 138 */
140 ExecutableMember(ExecutableElement baseElement, InterfaceType definingType, 139 ExecutableMember(ExecutableElement baseElement, InterfaceType definingType,
141 [FunctionType type]) 140 [FunctionType type])
scheglov 2016/02/10 21:53:26 [FunctionType this._type] maybe? OTOH this is not
Paul Berry 2016/02/10 22:10:59 Yeah, I had a similar thought. I think I'd prefer
142 : type = type ?? 141 : _type = type,
143 baseElement.type.substitute2(definingType.typeArguments,
144 TypeParameterTypeImpl.getTypes(definingType.typeParameters)),
145 super(baseElement, definingType); 142 super(baseElement, definingType);
146 143
147 @override 144 @override
148 ExecutableElement get baseElement => super.baseElement as ExecutableElement; 145 ExecutableElement get baseElement => super.baseElement as ExecutableElement;
149 146
150 @override 147 @override
151 List<FunctionElement> get functions { 148 List<FunctionElement> get functions {
152 // 149 //
153 // Elements within this element should have type parameters substituted, 150 // Elements within this element should have type parameters substituted,
154 // just like this element. 151 // just like this element.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // return getBaseElement().getLocalVariables(); 191 // return getBaseElement().getLocalVariables();
195 } 192 }
196 193
197 @override 194 @override
198 List<ParameterElement> get parameters => type.parameters; 195 List<ParameterElement> get parameters => type.parameters;
199 196
200 @override 197 @override
201 DartType get returnType => type.returnType; 198 DartType get returnType => type.returnType;
202 199
203 @override 200 @override
201 FunctionType get type {
202 return _type ??= baseElement.type.substitute2(definingType.typeArguments,
203 TypeParameterTypeImpl.getTypes(definingType.typeParameters));
204 }
205
206 @override
204 List<TypeParameterElement> get typeParameters => baseElement.typeParameters; 207 List<TypeParameterElement> get typeParameters => baseElement.typeParameters;
205 208
206 @override 209 @override
207 void visitChildren(ElementVisitor visitor) { 210 void visitChildren(ElementVisitor visitor) {
208 // TODO(brianwilkerson) We need to finish implementing the accessors used 211 // TODO(brianwilkerson) We need to finish implementing the accessors used
209 // below so that we can safely invoke them. 212 // below so that we can safely invoke them.
210 super.visitChildren(visitor); 213 super.visitChildren(visitor);
211 safelyVisitChildren(baseElement.functions, visitor); 214 safelyVisitChildren(baseElement.functions, visitor);
212 safelyVisitChildren(labels, visitor); 215 safelyVisitChildren(labels, visitor);
213 safelyVisitChildren(baseElement.localVariables, visitor); 216 safelyVisitChildren(baseElement.localVariables, visitor);
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 bool get isStatic => baseElement.isStatic; 962 bool get isStatic => baseElement.isStatic;
960 963
961 @override 964 @override
962 void visitChildren(ElementVisitor visitor) { 965 void visitChildren(ElementVisitor visitor) {
963 // TODO(brianwilkerson) We need to finish implementing the accessors used 966 // TODO(brianwilkerson) We need to finish implementing the accessors used
964 // below so that we can safely invoke them. 967 // below so that we can safely invoke them.
965 super.visitChildren(visitor); 968 super.visitChildren(visitor);
966 safelyVisitChild(baseElement.initializer, visitor); 969 safelyVisitChild(baseElement.initializer, visitor);
967 } 970 }
968 } 971 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | pkg/analyzer/lib/src/summary/resynthesize.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698