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

Side by Side Diff: lib/src/compiler/js_field_storage.dart

Issue 1966763004: always emit lazy field if overriding static (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 7 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 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'; 10 import 'extension_types.dart';
11 11
12 class PropertyOverrideResult { 12 class PropertyOverrideResult {
13 final bool foundGetter; 13 final bool foundGetter;
14 final bool foundSetter; 14 final bool foundSetter;
15 15
16 PropertyOverrideResult(this.foundGetter, this.foundSetter); 16 PropertyOverrideResult(this.foundGetter, this.foundSetter);
17 } 17 }
18 18
19 PropertyOverrideResult checkForPropertyOverride(FieldElement field, 19 PropertyOverrideResult checkForPropertyOverride(
20 List<ClassElement> superclasses, ExtensionTypeSet extensionTypes) { 20 FieldElement field, List<ClassElement> superclasses) {
21 bool foundGetter = false; 21 bool foundGetter = false;
22 bool foundSetter = false; 22 bool foundSetter = false;
23 23
24 for (var superclass in superclasses) { 24 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); 25 var superprop = getProperty(superclass, field.library, field.name);
29 if (superprop == null) continue; 26 if (superprop == null) continue;
30 27
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; 28 var getter = superprop.getter;
36 bool hasGetter = getter != null && !getter.isAbstract; 29 bool hasGetter = getter != null && !getter.isAbstract;
37 if (hasGetter) foundGetter = true; 30 if (hasGetter) foundGetter = true;
38 31
39 var setter = superprop.setter; 32 var setter = superprop.setter;
40 bool hasSetter = setter != null && !setter.isAbstract; 33 bool hasSetter = setter != null && !setter.isAbstract;
41 if (hasSetter) foundSetter = true; 34 if (hasSetter) foundSetter = true;
42 35
43 // Stop if this is an abstract getter/setter 36 // Stop if this is an abstract getter/setter
44 // TODO(jmesserly): why were we doing this? 37 // TODO(jmesserly): why were we doing this?
(...skipping 25 matching lines...) Expand all
70 if (mixin != null) result.add(mixin); 63 if (mixin != null) result.add(mixin);
71 } 64 }
72 var supertype = cls.supertype; 65 var supertype = cls.supertype;
73 if (supertype == null) break; 66 if (supertype == null) break;
74 67
75 cls = supertype.element; 68 cls = supertype.element;
76 result.add(cls); 69 result.add(cls);
77 } 70 }
78 return result; 71 return result;
79 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698