OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library kernel.incremental_class_hierarchy; | 4 library kernel.incremental_class_hierarchy; |
5 | 5 |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:math'; | 7 import 'dart:math'; |
8 | 8 |
9 import 'package:kernel/ast.dart'; | 9 import 'package:kernel/ast.dart'; |
10 import 'package:kernel/class_hierarchy.dart'; | 10 import 'package:kernel/class_hierarchy.dart'; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback); | 98 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback); |
99 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback, | 99 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback, |
100 onlyAbstract: true); | 100 onlyAbstract: true); |
101 | 101 |
102 _reportOverrides(info.implementedSetters, superSetters, callback, | 102 _reportOverrides(info.implementedSetters, superSetters, callback, |
103 isSetter: true); | 103 isSetter: true); |
104 _reportOverrides(info.declaredSetters, superSetters, callback, | 104 _reportOverrides(info.declaredSetters, superSetters, callback, |
105 isSetter: true, onlyAbstract: true); | 105 isSetter: true, onlyAbstract: true); |
106 } | 106 } |
107 if (!node.isAbstract) { | 107 // If a class declares an abstract method M whose |
108 // If a non-abstract class declares an abstract method M whose | 108 // implementation M' is inherited from the superclass, then the inherited |
109 // implementation M' is inherited from the superclass, then the inherited | 109 // method M' overrides the declared method M. |
110 // method M' overrides the declared method M. | 110 // This flies in the face of conventional override logic, but is necessary |
111 // This flies in the face of conventional override logic, but is necessary | 111 // because an instance of the class will contain the method M' which can |
112 // because an instance of the class will contain the method M' which can | 112 // be invoked through the interface of M. |
113 // be invoked through the interface of M. | 113 // Note that [_reportOverrides] does not report self-overrides, so in |
114 // Note that [_reportOverrides] does not report self-overrides, so in | 114 // most cases these calls will just scan both lists and report nothing. |
115 // most cases these calls will just scan both lists and report nothing. | 115 _reportOverrides(info.implementedGettersAndCalls, |
116 _reportOverrides(info.implementedGettersAndCalls, | 116 info.declaredGettersAndCalls, callback); |
117 info.declaredGettersAndCalls, callback); | 117 _reportOverrides(info.implementedSetters, info.declaredSetters, callback, |
118 _reportOverrides(info.implementedSetters, info.declaredSetters, callback, | 118 isSetter: true); |
119 isSetter: true); | |
120 } | |
121 } | 119 } |
122 | 120 |
123 @override | 121 @override |
124 void forEachCrossOverridePair(Class node, | 122 void forEachCrossOverridePair(Class node, |
125 callback(Member declaredMember, Member interfaceMember, bool isSetter), | 123 callback(Member declaredMember, Member interfaceMember, bool isSetter), |
126 {bool crossGettersSetters: false}) { | 124 {bool crossGettersSetters: false}) { |
127 _ClassInfo info = _getInfo(node); | 125 _ClassInfo info = _getInfo(node); |
128 for (var supertype in node.supers) { | 126 for (var supertype in node.supers) { |
129 var superNode = supertype.classNode; | 127 var superNode = supertype.classNode; |
130 var superInfo = _getInfo(superNode); | 128 var superInfo = _getInfo(superNode); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 class _LubHeap extends Heap<_ClassInfo> { | 741 class _LubHeap extends Heap<_ClassInfo> { |
744 @override | 742 @override |
745 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); | 743 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); |
746 | 744 |
747 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { | 745 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { |
748 if (a.depth > b.depth) return true; | 746 if (a.depth > b.depth) return true; |
749 if (a.depth < b.depth) return false; | 747 if (a.depth < b.depth) return false; |
750 return a.id < b.id; | 748 return a.id < b.id; |
751 } | 749 } |
752 } | 750 } |
OLD | NEW |