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

Side by Side Diff: pkg/kernel/lib/src/incremental_class_hierarchy.dart

Issue 2998383002: Fix forEachOverridePair in the case where the class in question is abstract. (Closed)
Patch Set: Rebase Created 3 years, 3 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
« no previous file with comments | « pkg/kernel/lib/class_hierarchy.dart ('k') | pkg/kernel/test/class_hierarchy_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/class_hierarchy.dart ('k') | pkg/kernel/test/class_hierarchy_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698