OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:collection' show HashMap, HashSet, Queue; | 5 import 'dart:collection' show HashMap, HashSet, Queue; |
6 | 6 |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/dart/element/type.dart' show InterfaceType; | 8 import 'package:analyzer/dart/element/type.dart' show InterfaceType; |
9 import 'package:analyzer/src/dart/element/element.dart' show FieldElementImpl; | 9 import 'package:analyzer/src/dart/element/element.dart' show FieldElementImpl; |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 /// The set of inherited setters, used because JS getters/setters are paired, | 183 /// The set of inherited setters, used because JS getters/setters are paired, |
184 /// so if we're generating a getter we may need to emit a setter that calls | 184 /// so if we're generating a getter we may need to emit a setter that calls |
185 /// super. | 185 /// super. |
186 final inheritedSetters = new HashSet<String>(); | 186 final inheritedSetters = new HashSet<String>(); |
187 | 187 |
188 final mockMembers = <String, ExecutableElement>{}; | 188 final mockMembers = <String, ExecutableElement>{}; |
189 | 189 |
190 final extensionMembers = new Set<ExecutableElement>(); | 190 final extensionMembers = new Set<ExecutableElement>(); |
191 final mixinExtensionMembers = new Set<ExecutableElement>(); | 191 final mixinExtensionMembers = new Set<ExecutableElement>(); |
192 | 192 |
193 ClassPropertyModel.build(ExtensionTypeSet extensionTypes, | 193 /// Parameters that are covariant due to covariant generics. |
194 VirtualFieldModel fieldModel, ClassElement classElem) { | 194 final Set<Element> covariantParameters; |
| 195 |
| 196 ClassPropertyModel.build( |
| 197 ExtensionTypeSet extensionTypes, |
| 198 VirtualFieldModel fieldModel, |
| 199 ClassElement classElem, |
| 200 this.covariantParameters, |
| 201 Set<ExecutableElement> covariantPrivateMembers) { |
195 // Visit superclasses to collect information about their fields/accessors. | 202 // Visit superclasses to collect information about their fields/accessors. |
196 // This is expensive so we try to collect everything in one pass. | 203 // This is expensive so we try to collect everything in one pass. |
197 for (var base in getSuperclasses(classElem)) { | 204 for (var base in getSuperclasses(classElem)) { |
198 for (var accessor in base.accessors) { | 205 for (var accessor in base.accessors) { |
199 // For getter/setter pairs only process them once. | 206 // For getter/setter pairs only process them once. |
200 if (accessor.correspondingGetter != null) continue; | 207 if (accessor.correspondingGetter != null) continue; |
201 | 208 |
202 var field = accessor.variable; | 209 var field = accessor.variable; |
203 // Ignore private names from other libraries. | 210 // Ignore private names from other libraries. |
204 if (field.isPrivate && accessor.library != classElem.library) { | 211 if (field.isPrivate && accessor.library != classElem.library) { |
(...skipping 21 matching lines...) Expand all Loading... |
226 for (var accessor in classElem.accessors) { | 233 for (var accessor in classElem.accessors) { |
227 // For getter/setter pairs only process them once. | 234 // For getter/setter pairs only process them once. |
228 if (accessor.correspondingGetter != null) continue; | 235 if (accessor.correspondingGetter != null) continue; |
229 // Also ignore abstract fields. | 236 // Also ignore abstract fields. |
230 if (accessor.isAbstract) continue; | 237 if (accessor.isAbstract) continue; |
231 | 238 |
232 var field = accessor.variable; | 239 var field = accessor.variable; |
233 var name = field.name; | 240 var name = field.name; |
234 // Is it a field? | 241 // Is it a field? |
235 if (!field.isSynthetic && field is FieldElementImpl) { | 242 if (!field.isSynthetic && field is FieldElementImpl) { |
| 243 var setter = field.setter; |
236 if (virtualAccessorNames.contains(name) || | 244 if (virtualAccessorNames.contains(name) || |
237 fieldModel.isVirtual(field)) { | 245 fieldModel.isVirtual(field) || |
| 246 setter != null && |
| 247 covariantParameters != null && |
| 248 covariantParameters.contains(setter.parameters[0]) && |
| 249 covariantPrivateMembers.contains(setter)) { |
238 if (field.isStatic) { | 250 if (field.isStatic) { |
239 staticFieldOverrides.add(field); | 251 staticFieldOverrides.add(field); |
240 } else { | 252 } else { |
241 virtualFields[field] = new JS.TemporaryId(name); | 253 virtualFields[field] = new JS.TemporaryId(name); |
242 } | 254 } |
243 } | 255 } |
244 } | 256 } |
245 } | 257 } |
246 } | 258 } |
247 | 259 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 333 } |
322 } | 334 } |
323 | 335 |
324 visitType(type, false); | 336 visitType(type, false); |
325 | 337 |
326 for (var m in mockMembers.values) { | 338 for (var m in mockMembers.values) { |
327 if (possibleExtensions.contains(m.name)) extensionMembers.add(m); | 339 if (possibleExtensions.contains(m.name)) extensionMembers.add(m); |
328 } | 340 } |
329 } | 341 } |
330 } | 342 } |
OLD | NEW |