OLD | NEW |
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 import 'dart:collection' show HashSet; | 5 import 'dart:collection' show HashSet; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart' show Identifier; | 7 import 'package:analyzer/dart/ast/ast.dart' show Identifier; |
8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
9 | 9 |
10 import 'extension_types.dart'; | |
11 | |
12 class PropertyOverrideResult { | 10 class PropertyOverrideResult { |
13 final bool foundGetter; | 11 final bool foundGetter; |
14 final bool foundSetter; | 12 final bool foundSetter; |
15 | 13 |
16 PropertyOverrideResult(this.foundGetter, this.foundSetter); | 14 PropertyOverrideResult(this.foundGetter, this.foundSetter); |
17 } | 15 } |
18 | 16 |
19 PropertyOverrideResult checkForPropertyOverride(FieldElement field, | 17 PropertyOverrideResult checkForPropertyOverride( |
20 List<ClassElement> superclasses, ExtensionTypeSet extensionTypes) { | 18 FieldElement field, List<ClassElement> superclasses) { |
21 bool foundGetter = false; | 19 bool foundGetter = false; |
22 bool foundSetter = false; | 20 bool foundSetter = false; |
23 | 21 |
24 for (var superclass in superclasses) { | 22 for (var superclass in superclasses) { |
25 // Stop if we reach a native type. | |
26 if (extensionTypes.isNativeClass(superclass)) break; | |
27 | |
28 var superprop = getProperty(superclass, field.library, field.name); | 23 var superprop = getProperty(superclass, field.library, field.name); |
29 if (superprop == null) continue; | 24 if (superprop == null) continue; |
30 | 25 |
31 // Static fields can override superclass static fields. However, we need to | |
32 // handle the case where they override a getter or setter. | |
33 if (field.isStatic && !superprop.isSynthetic) continue; | |
34 | |
35 var getter = superprop.getter; | 26 var getter = superprop.getter; |
36 bool hasGetter = getter != null && !getter.isAbstract; | 27 bool hasGetter = getter != null && !getter.isAbstract; |
37 if (hasGetter) foundGetter = true; | 28 if (hasGetter) foundGetter = true; |
38 | 29 |
39 var setter = superprop.setter; | 30 var setter = superprop.setter; |
40 bool hasSetter = setter != null && !setter.isAbstract; | 31 bool hasSetter = setter != null && !setter.isAbstract; |
41 if (hasSetter) foundSetter = true; | 32 if (hasSetter) foundSetter = true; |
42 | 33 |
43 // Stop if this is an abstract getter/setter | 34 // Stop if this is an abstract getter/setter |
44 // TODO(jmesserly): why were we doing this? | 35 // TODO(jmesserly): why were we doing this? |
(...skipping 25 matching lines...) Expand all Loading... |
70 if (mixin != null) result.add(mixin); | 61 if (mixin != null) result.add(mixin); |
71 } | 62 } |
72 var supertype = cls.supertype; | 63 var supertype = cls.supertype; |
73 if (supertype == null) break; | 64 if (supertype == null) break; |
74 | 65 |
75 cls = supertype.element; | 66 cls = supertype.element; |
76 result.add(cls); | 67 result.add(cls); |
77 } | 68 } |
78 return result; | 69 return result; |
79 } | 70 } |
OLD | NEW |