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

Side by Side Diff: pkg/kernel/lib/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 | « no previous file | pkg/kernel/lib/src/incremental_class_hierarchy.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.class_hierarchy; 4 library kernel.class_hierarchy;
5 5
6 import 'ast.dart'; 6 import 'ast.dart';
7 import 'dart:math'; 7 import 'dart:math';
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 import 'src/heap.dart'; 9 import 'src/heap.dart';
10 import 'type_algebra.dart'; 10 import 'type_algebra.dart';
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 var superGetters = getInterfaceMembers(superclass); 410 var superGetters = getInterfaceMembers(superclass);
411 var superSetters = getInterfaceMembers(superclass, setters: true); 411 var superSetters = getInterfaceMembers(superclass, setters: true);
412 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback); 412 _reportOverrides(info.implementedGettersAndCalls, superGetters, callback);
413 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback, 413 _reportOverrides(info.declaredGettersAndCalls, superGetters, callback,
414 onlyAbstract: true); 414 onlyAbstract: true);
415 _reportOverrides(info.implementedSetters, superSetters, callback, 415 _reportOverrides(info.implementedSetters, superSetters, callback,
416 isSetter: true); 416 isSetter: true);
417 _reportOverrides(info.declaredSetters, superSetters, callback, 417 _reportOverrides(info.declaredSetters, superSetters, callback,
418 isSetter: true, onlyAbstract: true); 418 isSetter: true, onlyAbstract: true);
419 } 419 }
420 if (!class_.isAbstract) { 420 // If a class declares an abstract method M whose
421 // If a non-abstract class declares an abstract method M whose 421 // implementation M' is inherited from the superclass, then the inherited
422 // implementation M' is inherited from the superclass, then the inherited 422 // method M' overrides the declared method M.
423 // method M' overrides the declared method M. 423 // This flies in the face of conventional override logic, but is necessary
424 // This flies in the face of conventional override logic, but is necessary 424 // because an instance of the class will contain the method M' which can
425 // because an instance of the class will contain the method M' which can 425 // be invoked through the interface of M.
426 // be invoked through the interface of M. 426 // Note that [_reportOverrides] does not report self-overrides, so in
427 // Note that [_reportOverrides] does not report self-overrides, so in 427 // most cases these calls will just scan both lists and report nothing.
428 // most cases these calls will just scan both lists and report nothing. 428 _reportOverrides(info.implementedGettersAndCalls,
429 _reportOverrides(info.implementedGettersAndCalls, 429 info.declaredGettersAndCalls, callback);
430 info.declaredGettersAndCalls, callback); 430 _reportOverrides(info.implementedSetters, info.declaredSetters, callback,
431 _reportOverrides(info.implementedSetters, info.declaredSetters, callback, 431 isSetter: true);
432 isSetter: true);
433 }
434 } 432 }
435 433
436 @override 434 @override
437 void forEachCrossOverridePair(Class class_, 435 void forEachCrossOverridePair(Class class_,
438 callback(Member declaredMember, Member interfaceMember, bool isSetter), 436 callback(Member declaredMember, Member interfaceMember, bool isSetter),
439 {bool crossGettersSetters: false}) { 437 {bool crossGettersSetters: false}) {
440 _ClassInfo info = _infoFor[class_]; 438 _ClassInfo info = _infoFor[class_];
441 for (var supertype in class_.supers) { 439 for (var supertype in class_.supers) {
442 var superclass = supertype.classNode; 440 var superclass = supertype.classNode;
443 var superGetters = getInterfaceMembers(superclass); 441 var superGetters = getInterfaceMembers(superclass);
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 class _LubHeap extends Heap<_ClassInfo> { 1169 class _LubHeap extends Heap<_ClassInfo> {
1172 @override 1170 @override
1173 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b); 1171 bool sortsBefore(_ClassInfo a, _ClassInfo b) => sortsBeforeStatic(a, b);
1174 1172
1175 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) { 1173 static bool sortsBeforeStatic(_ClassInfo a, _ClassInfo b) {
1176 if (a.depth > b.depth) return true; 1174 if (a.depth > b.depth) return true;
1177 if (a.depth < b.depth) return false; 1175 if (a.depth < b.depth) return false;
1178 return a.topologicalIndex < b.topologicalIndex; 1176 return a.topologicalIndex < b.topologicalIndex;
1179 } 1177 }
1180 } 1178 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/lib/src/incremental_class_hierarchy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698