Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/resolver/Elements.java |
| diff --git a/compiler/java/com/google/dart/compiler/resolver/Elements.java b/compiler/java/com/google/dart/compiler/resolver/Elements.java |
| index a78636ced9842489c5c1b752dca9c470fdf5376d..3d51062186523d248780fa3ca3c34c18f37a4d1d 100644 |
| --- a/compiler/java/com/google/dart/compiler/resolver/Elements.java |
| +++ b/compiler/java/com/google/dart/compiler/resolver/Elements.java |
| @@ -14,6 +14,7 @@ import com.google.dart.compiler.LibrarySource; |
| import com.google.dart.compiler.Source; |
| import com.google.dart.compiler.ast.DartClass; |
| import com.google.dart.compiler.ast.DartClassMember; |
| +import com.google.dart.compiler.ast.DartClassTypeAlias; |
| import com.google.dart.compiler.ast.DartField; |
| import com.google.dart.compiler.ast.DartFunctionExpression; |
| import com.google.dart.compiler.ast.DartFunctionTypeAlias; |
| @@ -64,6 +65,10 @@ public class Elements { |
| static void addInterface(ClassElement classElement, InterfaceType type) { |
| ((ClassElementImplementation) classElement).addInterface(type); |
| } |
| + |
| + static void addMixin(ClassElement classElement, InterfaceType type) { |
| + ((ClassElementImplementation) classElement).addMixin(type); |
| + } |
| static LabelElement statementLabelElement(DartLabel node, String name, |
| MethodElement enclosingFunction) { |
| @@ -236,6 +241,10 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| static ClassElement classFromNode(DartClass node, LibraryElement library) { |
| return ClassElementImplementation.fromNode(node, library); |
| } |
| + |
| + static ClassAliasElement classFromNode(DartClassTypeAlias node, LibraryElement library) { |
| + return ClassElementImplementation.fromNode(node, library); |
| + } |
| public static ClassElement classNamed(String name) { |
| return ClassElementImplementation.named(name); |
| @@ -302,29 +311,30 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| } |
| /** |
| - * @return <code>non-null</code> {@link MethodElement} if "holder", or one of its |
| - * interfaces, or its superclass has {@link FieldElement} with getter. |
| + * @return <code>not-null</code> {@link MethodElement} if "holder", or one of its interfaces, or |
| + * its superclass has {@link FieldElement} with getter. |
| */ |
| public static MethodElement lookupFieldElementGetter(EnclosingElement holder, String name) { |
| - Element element = holder.lookupLocalElement(name); |
| - if (element instanceof FieldElement) { |
| - FieldElement fieldElement = (FieldElement) element; |
| - MethodElement result = fieldElement.getGetter(); |
| - if (result != null) { |
| - return fieldElement.getGetter(); |
| - } |
| + MethodElement result = lookupFieldElementGetter0(holder, name); |
| + if (result != null) { |
| + return result; |
| } |
| if (holder instanceof ClassElement) { |
| ClassElement classHolder = (ClassElement) holder; |
| for (InterfaceType interfaceType : classHolder.getInterfaces()) { |
| - MethodElement result = lookupFieldElementGetter(interfaceType.getElement(), name); |
| + result = lookupFieldElementGetter(interfaceType.getElement(), name); |
| + if (result != null) { |
| + return result; |
| + } |
| + } |
| + for (InterfaceType mixinType : classHolder.getMixins()) { |
| + result = lookupFieldElementGetter0(mixinType.getElement(), name); |
| if (result != null) { |
| return result; |
| } |
| } |
| if (classHolder.getSupertype() != null) { |
| - MethodElement result = lookupFieldElementGetter(classHolder.getSupertype().getElement(), |
| - name); |
| + result = lookupFieldElementGetter(classHolder.getSupertype().getElement(), name); |
| if (result != null) { |
| return result; |
| } |
| @@ -335,29 +345,45 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| } |
| /** |
| - * @return <code>non-null</code> {@link MethodElement} if "holder", or one of its interfaces, |
| - * or its superclass has {@link FieldElement} with setter. |
| + * @return the {@link MethodElement} if "holder" has {@link FieldElement} with getter. |
| */ |
| - public static MethodElement lookupFieldElementSetter(EnclosingElement holder, String name) { |
| + private static MethodElement lookupFieldElementGetter0(EnclosingElement holder, String name) { |
| Element element = holder.lookupLocalElement(name); |
| if (element instanceof FieldElement) { |
| FieldElement fieldElement = (FieldElement) element; |
| - MethodElement result = fieldElement.getSetter(); |
| + MethodElement result = fieldElement.getGetter(); |
| if (result != null) { |
| - return result; |
| + return fieldElement.getGetter(); |
| } |
| } |
| + return null; |
| + } |
| + |
| + /** |
| + * @return <code>non-null</code> {@link MethodElement} if "holder", or one of its interfaces, or |
| + * its superclass has {@link FieldElement} with setter. |
| + */ |
| + public static MethodElement lookupFieldElementSetter(EnclosingElement holder, String name) { |
| + MethodElement result = lookupFieldElementSetter0(holder, name); |
| + if (result != null) { |
| + return result; |
| + } |
| if (holder instanceof ClassElement) { |
| - ClassElement classHolder = (ClassElement)holder; |
| + ClassElement classHolder = (ClassElement) holder; |
| for (InterfaceType interfaceType : classHolder.getInterfaces()) { |
| - MethodElement result = lookupFieldElementSetter(interfaceType.getElement(), name); |
| + result = lookupFieldElementSetter(interfaceType.getElement(), name); |
| + if (result != null) { |
| + return result; |
| + } |
| + } |
| + for (InterfaceType mixinType : classHolder.getMixins()) { |
| + result = lookupFieldElementSetter(mixinType.getElement(), name); |
|
Brian Wilkerson
2013/01/09 16:17:41
I believe that this needs to invoke lookupFieldEle
|
| if (result != null) { |
| return result; |
| } |
| } |
| if (classHolder.getSupertype() != null) { |
| - MethodElement result = lookupFieldElementSetter(classHolder.getSupertype().getElement(), |
| - name); |
| + result = lookupFieldElementSetter(classHolder.getSupertype().getElement(), name); |
| if (result != null) { |
| return result; |
| } |
| @@ -367,6 +393,21 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| } |
| /** |
| + * @return the {@link MethodElement} if "holder" has {@link FieldElement} with setter. |
| + */ |
| + private static MethodElement lookupFieldElementSetter0(EnclosingElement holder, String name) { |
| + Element element = holder.lookupLocalElement(name); |
| + if (element instanceof FieldElement) { |
| + FieldElement fieldElement = (FieldElement) element; |
| + MethodElement result = fieldElement.getSetter(); |
| + if (result != null) { |
| + return result; |
| + } |
| + } |
| + return null; |
| + } |
| + |
| + /** |
| * @return <code>true</code> if {@link DartNode} of given {@link Element} if part of static |
| * {@link DartClassMember} or part of top level declaration. |
| */ |
| @@ -842,6 +883,11 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| return true; |
| } |
| } |
| + for (InterfaceType mixinType : clazz.getMixins()) { |
| + if (mixinType.getElement().lookupLocalElement(name) != null) { |
| + return true; |
| + } |
| + } |
| if (clazz.getSupertype() != null) { |
| if (hasClassMember(clazz.getSupertype().getElement(), name)) { |
| return true; |
| @@ -900,6 +946,9 @@ static FieldElementImplementation fieldFromNode(DartField node, |
| for (InterfaceType intf : classElement.getInterfaces()) { |
| addAllMembers(visited, allMembers, intf.getElement()); |
| } |
| + for (InterfaceType mix : classElement.getMixins()) { |
| + Iterables.addAll(allMembers, mix.getElement().getMembers()); |
| + } |
| } |
| public static boolean isAbstractElement(Element element) { |