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

Side by Side Diff: lib/compiler/implementation/universe/universe.dart

Issue 11315005: Fix for issue #6259: also look for subclasses when checking if a typed selector applies to an eleme… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/typed_selector_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library universe; 5 library universe;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../dart2jslib.dart'; 9 import '../dart2jslib.dart';
10 import '../runtime_types.dart'; 10 import '../runtime_types.dart';
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // class A { 516 // class A {
517 // get foo => () => 42; 517 // get foo => () => 42;
518 // bar() => foo(); // The call to 'foo' is a typed selector. 518 // bar() => foo(); // The call to 'foo' is a typed selector.
519 // } 519 // }
520 ClassElement other = element.getEnclosingClass(); 520 ClassElement other = element.getEnclosingClass();
521 if (identical(other.superclass, compiler.closureClass)) { 521 if (identical(other.superclass, compiler.closureClass)) {
522 return appliesUntyped(element, compiler); 522 return appliesUntyped(element, compiler);
523 } 523 }
524 524
525 ClassElement self = receiverType.element; 525 ClassElement self = receiverType.element;
526 if (other.implementsInterface(self) || other.isSubclassOf(self)) { 526
527 // Checks if a subclass of [superClass] implements [self]. If one
528 // is found, [element] is a candidate.
529 bool hasOneSubclassThatImplements(ClassElement superClass) {
ahe 2012/10/29 06:18:29 Have you measured the compile-time impact of this?
530 // [TypedSelector] are only used when compiling.
531 assert(compiler.phase == Compiler.PHASE_COMPILING);
532 Set<ClassElement> subclasses = compiler.world.subtypes[superClass];
533 if (subclasses == null) return false;
534 for (ClassElement cls in subclasses) {
535 if (cls.implementsInterface(self)) return true;
536 }
537 return false;
538 }
539
540 if (other.implementsInterface(self)
541 || other.isSubclassOf(self)
542 || hasOneSubclassThatImplements(other)) {
527 return appliesUntyped(element, compiler); 543 return appliesUntyped(element, compiler);
528 } 544 }
529 545
530 if (!self.isInterface() && self.isSubclassOf(other)) { 546 if (!self.isInterface() && self.isSubclassOf(other)) {
531 // Resolve an invocation of [element.name] on [self]. If it 547 // Resolve an invocation of [element.name] on [self]. If it
532 // is found, this selector is a candidate. 548 // is found, this selector is a candidate.
533 return hasElementIn(self, element) && appliesUntyped(element, compiler); 549 return hasElementIn(self, element) && appliesUntyped(element, compiler);
534 } 550 }
535 551
536 return false; 552 return false;
537 } 553 }
538 } 554 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/typed_selector_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698