| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 final Map<Class, _ClassInfo> _info = new LinkedHashMap<Class, _ClassInfo>(); | 79 final Map<Class, _ClassInfo> _info = new LinkedHashMap<Class, _ClassInfo>(); |
| 80 | 80 |
| 81 @override | 81 @override |
| 82 ClassHierarchy applyChanges(Iterable<Class> classes) { | 82 ClassHierarchy applyChanges(Iterable<Class> classes) { |
| 83 if (classes.isEmpty) return this; | 83 if (classes.isEmpty) return this; |
| 84 return new IncrementalClassHierarchy(); | 84 return new IncrementalClassHierarchy(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @override | 87 @override |
| 88 void forEachOverridePair(Class node, | 88 void forEachOverridePair(Class node, |
| 89 callback(Member declaredMember, Member interfaceMember, bool isSetter)) { | 89 callback(Member declaredMember, Member interfaceMember, bool isSetter), |
| 90 {bool crossGettersSetters: false}) { |
| 90 _ClassInfo info = _getInfo(node); | 91 _ClassInfo info = _getInfo(node); |
| 91 for (var supertype in node.supers) { | 92 for (var supertype in node.supers) { |
| 92 var superNode = supertype.classNode; | 93 var superNode = supertype.classNode; |
| 93 var superInfo = _getInfo(superNode); | 94 var superInfo = _getInfo(superNode); |
| 94 | 95 |
| 95 var superGetters = superInfo.interfaceGettersAndCalls; | 96 var superGetters = superInfo.interfaceGettersAndCalls; |
| 97 var superSetters = superInfo.interfaceSetters; |
| 98 |
| 96 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback); | 99 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback); |
| 97 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback, | 100 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback, |
| 98 onlyAbstract: true); | 101 onlyAbstract: true); |
| 99 | 102 |
| 100 var superSetters = superInfo.interfaceSetters; | |
| 101 _reportOverrides(info.implementedSetters, superSetters, callback, | 103 _reportOverrides(info.implementedSetters, superSetters, callback, |
| 102 isSetter: true); | 104 isSetter: true); |
| 103 _reportOverrides(info.declaredSetters, superSetters, callback, | 105 _reportOverrides(info.declaredSetters, superSetters, callback, |
| 104 isSetter: true, onlyAbstract: true); | 106 isSetter: true, onlyAbstract: true); |
| 107 |
| 108 if (crossGettersSetters) { |
| 109 _reportOverrides(info.declaredGettersAndCalls, superSetters, callback); |
| 110 _reportOverrides(info.declaredSetters, superGetters, callback); |
| 111 } |
| 105 } | 112 } |
| 106 if (!node.isAbstract) { | 113 if (!node.isAbstract) { |
| 107 // If a non-abstract class declares an abstract method M whose | 114 // If a non-abstract class declares an abstract method M whose |
| 108 // implementation M' is inherited from the superclass, then the inherited | 115 // implementation M' is inherited from the superclass, then the inherited |
| 109 // method M' overrides the declared method M. | 116 // method M' overrides the declared method M. |
| 110 // This flies in the face of conventional override logic, but is necessary | 117 // 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 | 118 // because an instance of the class will contain the method M' which can |
| 112 // be invoked through the interface of M. | 119 // be invoked through the interface of M. |
| 113 // Note that [_reportOverrides] does not report self-overrides, so in | 120 // Note that [_reportOverrides] does not report self-overrides, so in |
| 114 // most cases these calls will just scan both lists and report nothing. | 121 // most cases these calls will just scan both lists and report nothing. |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 class _LubHeap extends Heap<_ClassInfo> { | 725 class _LubHeap extends Heap<_ClassInfo> { |
| 719 @override | 726 @override |
| 720 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); | 727 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); |
| 721 | 728 |
| 722 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { | 729 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { |
| 723 if (a.depth > b.depth) return true; | 730 if (a.depth > b.depth) return true; |
| 724 if (a.depth < b.depth) return false; | 731 if (a.depth < b.depth) return false; |
| 725 return a.id < b.id; | 732 return a.id < b.id; |
| 726 } | 733 } |
| 727 } | 734 } |
| OLD | NEW |