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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/world.dart

Issue 12328035: Teach Selector.applies about mixins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 part of dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Map<ClassElement, Set<ClassElement>> subtypes; 9 final Map<ClassElement, Set<ClassElement>> subtypes;
10 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; 10 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return allFunctions.filter(selector).any((each) => each.isSetter()); 123 return allFunctions.filter(selector).any((each) => each.isSetter());
124 } 124 }
125 125
126 // Returns whether a subclass of [superclass] implements [type]. 126 // Returns whether a subclass of [superclass] implements [type].
127 bool hasAnySubclassThatImplements(ClassElement superclass, DartType type) { 127 bool hasAnySubclassThatImplements(ClassElement superclass, DartType type) {
128 Set<ClassElement> subclasses = typesImplementedBySubclasses[superclass]; 128 Set<ClassElement> subclasses = typesImplementedBySubclasses[superclass];
129 if (subclasses == null) return false; 129 if (subclasses == null) return false;
130 return subclasses.contains(type.element); 130 return subclasses.contains(type.element);
131 } 131 }
132 132
133 // Returns whether a subclass of [superclass] mixes in [other].
134 bool hasAnySubclassThatMixes(ClassElement superclass, ClassElement other) {
135 Set<MixinApplicationElement> uses = mixinUses[other];
136 return (uses != null)
Lasse Reichstein Nielsen 2013/02/21 09:32:05 x ? y : false => x && y
137 ? uses.any((each) => each.isSubclassOf(superclass))
138 : false;
139 }
140
133 void registerUsedElement(Element element) { 141 void registerUsedElement(Element element) {
134 if (element.isInstanceMember() && !element.isAbstract(compiler)) { 142 if (element.isInstanceMember() && !element.isAbstract(compiler)) {
135 allFunctions.add(element); 143 allFunctions.add(element);
136 } 144 }
137 } 145 }
138 146
139 VariableElement locateSingleField(Selector selector) { 147 VariableElement locateSingleField(Selector selector) {
140 Element result = locateSingleElement(selector); 148 Element result = locateSingleElement(selector);
141 return (result != null && result.isField()) ? result : null; 149 return (result != null && result.isField()) ? result : null;
142 } 150 }
(...skipping 21 matching lines...) Expand all
164 noSuchMethodSelector = new TypedSelector( 172 noSuchMethodSelector = new TypedSelector(
165 receiverType, selector.typeKind, noSuchMethodSelector); 173 receiverType, selector.typeKind, noSuchMethodSelector);
166 } 174 }
167 ClassElement objectClass = compiler.objectClass; 175 ClassElement objectClass = compiler.objectClass;
168 return allFunctions 176 return allFunctions
169 .filter(noSuchMethodSelector) 177 .filter(noSuchMethodSelector)
170 .map((Element member) => member.getEnclosingClass()) 178 .map((Element member) => member.getEnclosingClass())
171 .where((ClassElement holder) => !identical(holder, objectClass)); 179 .where((ClassElement holder) => !identical(holder, objectClass));
172 } 180 }
173 } 181 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/universe/universe.dart ('k') | tests/language/mixin_override_regression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698