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

Unified Diff: compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java

Issue 11293058: Issue 5157. Introduce TypeQuality. Try to find member in subclasses. (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
diff --git a/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java b/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
index a7ab8d64ab094c2dfa186ad53fc4e5eef1289e30..fac151a68bf2889a326fc71679b8e1bc3582d9d6 100644
--- a/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
+++ b/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
@@ -4,6 +4,7 @@
package com.google.dart.compiler.type;
+import com.google.common.collect.MapMaker;
import com.google.dart.compiler.resolver.ClassElement;
import com.google.dart.compiler.resolver.Element;
import com.google.dart.compiler.resolver.ElementKind;
@@ -15,6 +16,7 @@ import com.google.dart.compiler.util.apache.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
/**
* An interface type.
@@ -22,6 +24,7 @@ import java.util.List;
class InterfaceTypeImplementation extends AbstractType implements InterfaceType {
private final ClassElement element;
private final List<Type> arguments;
+ private final Map<ClassElement, Object> subClasses = new MapMaker().weakKeys().makeMap();
InterfaceTypeImplementation(ClassElement element, List<Type> arguments) {
this.element = element;
@@ -217,4 +220,34 @@ class InterfaceTypeImplementation extends AbstractType implements InterfaceType
return getterType.subst(typeArguments, typeParameters);
}
}
+
+ @Override
+ public void registerSubClass(ClassElement subClass) {
+ subClasses.put(subClass, this);
+ }
+
+ @Override
+ public void unregisterSubClass(ClassElement subClass) {
+ subClasses.remove(subClass);
+ }
+
+ @Override
+ public Member lookupSubTypeMember(String name) {
+ for (ClassElement subClass : subClasses.keySet()) {
+ {
+ Element element = subClass.lookupLocalElement(name);
+ if (element != null) {
+ return new MemberImplementation(this, element);
+ }
+ }
+ InterfaceType type = subClass.getType();
+ if (type != null) {
+ Member member = type.lookupSubTypeMember(name);
+ if (member != null) {
+ return member;
+ }
+ }
+ }
+ return null;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698