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

Unified Diff: sdk/lib/_internal/compiler/implementation/types/flat_type_mask.dart

Issue 23447011: A typed selector needs no such method handling if at least one of its implemented subtype (in case … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/no_such_method_subtype_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/types/flat_type_mask.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/types/flat_type_mask.dart (revision 27025)
+++ sdk/lib/_internal/compiler/implementation/types/flat_type_mask.dart (working copy)
@@ -496,8 +496,9 @@
}
bool needsNoSuchMethodHandling(Selector selector, Compiler compiler) {
- // A call on an empty type mask is dead code.
- if (isEmpty && !isNullable) return false;
+ // A call on an empty type mask is either dead code, or a call on
+ // `null`.
+ if (isEmpty) return false;
// A call on an exact mask for an abstract class is dead code.
if (isExact && base.element.isAbstract(compiler)) return false;
// If the receiver is guaranteed to have a member that
@@ -541,7 +542,25 @@
// If we're calling bar on an object of type A we do need the
// handler because we may have to call B.noSuchMethod since B
// does not implement bar.
- return !willHit(selector, compiler);
+
+ Element cls = base.element;
+ bool hasMatch = hasConcreteMatch(cls, selector, compiler);
+ if (isExact) return !hasMatch;
+ if (!cls.isAbstract(compiler) && !hasMatch) return true;
+
+ Set<ClassElement> subtypesToCheck;
+ if (isSubtype) {
+ subtypesToCheck = compiler.world.subtypesOf(cls);
+ } else {
+ assert(isSubclass);
+ subtypesToCheck = compiler.world.subclassesOf(cls);
+ }
+
+ return subtypesToCheck != null
+ && subtypesToCheck.any((ClassElement cls) {
+ return !cls.isAbstract(compiler)
ahe 2013/09/04 12:17:49 Why the check for isAbstract?
ngeoffray 2013/09/04 12:32:23 If an abstract class does not have a concrete matc
ahe 2013/09/04 12:39:54 Thank you. Add a comment?
+ && !hasConcreteMatch(cls, selector, compiler);
+ });
}
Element locateSingleElement(Selector selector, Compiler compiler) {
« no previous file with comments | « no previous file | tests/language/no_such_method_subtype_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698