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

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

Issue 11776037: Initial support for mixins in dartc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Forgot MixinScope.java Created 7 years, 11 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
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 52c63ce6a4698f42a7fb2294e8601b0584f341b4..9997711c666c507592717658ea2b6d7db56a59c7 100644
--- a/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
+++ b/compiler/java/com/google/dart/compiler/type/InterfaceTypeImplementation.java
@@ -106,23 +106,37 @@ class InterfaceTypeImplementation extends AbstractType implements InterfaceType
@Override
public Member lookupMember(String name) {
- Element element = getElement().lookupLocalElement(name);
- if (element != null) {
- return new MemberImplementation(this, element);
+ Member member = lookupMember0(this, name);
+ if (member != null) {
+ return member;
}
InterfaceType supertype = getSupertype();
if (supertype != null) {
- Member member = supertype.lookupMember(name);
+ member = supertype.lookupMember(name);
if (member != null) {
return member;
}
}
for (InterfaceType intrface : getInterfaces()) {
- Member member = intrface.lookupMember(name);
+ member = intrface.lookupMember(name);
if (member != null) {
return member;
}
}
+ for (InterfaceType intrface : getMixins()) {
Brian Wilkerson 2013/01/09 16:17:41 nit: "intrface" --> "mixin"
+ member = lookupMember0(intrface, name);
+ if (member != null) {
+ return member;
+ }
+ }
+ return null;
+ }
+
+ private static Member lookupMember0(InterfaceType type, String name) {
+ Element element = type.getElement().lookupLocalElement(name);
+ if (element != null) {
+ return new MemberImplementation(type, element);
+ }
return null;
}
@@ -136,11 +150,20 @@ class InterfaceTypeImplementation extends AbstractType implements InterfaceType
}
private List<InterfaceType> getInterfaces() {
- List<InterfaceType> interfaces = getElement().getInterfaces();
- List<InterfaceType> result = new ArrayList<InterfaceType>(interfaces.size());
+ List<InterfaceType> result = new ArrayList<InterfaceType>();
+ List<Type> typeArguments = getArguments();
+ List<Type> typeParameters = getElement().getTypeParameters();
+ for (InterfaceType type : getElement().getInterfaces()) {
+ result.add(type.subst(typeArguments, typeParameters));
+ }
+ return result;
+ }
+
+ private List<InterfaceType> getMixins() {
+ List<InterfaceType> result = new ArrayList<InterfaceType>();
List<Type> typeArguments = getArguments();
List<Type> typeParameters = getElement().getTypeParameters();
- for (InterfaceType type : interfaces) {
+ for (InterfaceType type : getElement().getMixins()) {
result.add(type.subst(typeArguments, typeParameters));
}
return result;

Powered by Google App Engine
This is Rietveld 408576698