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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java

Issue 9122003: Issue 1061: Duplicate members causes NPE in type analyzer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: whitespace Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
index b831fdc4cf5ff6cc11015ac111ec3703958e73b2..e3957734ccc10d61050ac18d4c9a4bb767b86b19 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
@@ -4,6 +4,8 @@
package com.google.dart.compiler.resolver;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartDeclaration;
import com.google.dart.compiler.ast.DartStringLiteral;
@@ -16,7 +18,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -38,7 +39,7 @@ class ClassElementImplementation extends AbstractElement implements ClassElement
private volatile Set<InterfaceType> subtypes;
private final List<ConstructorElement> constructors;
- private final Map<String, Element> members;
+ private final Multimap<String, Element> members;
private final LibraryElement library;
@@ -55,7 +56,7 @@ class ClassElementImplementation extends AbstractElement implements ClassElement
this.nativeName = nativeName;
this.library = library;
constructors = new ArrayList<ConstructorElement>();
- members = new LinkedHashMap<String, Element>();
+ members = LinkedHashMultimap.create();
interfaces = new ArrayList<InterfaceType>();
if (node != null) {
isInterface = node.isInterface();
@@ -221,11 +222,12 @@ class ClassElementImplementation extends AbstractElement implements ClassElement
Element findElement(String name) {
// Temporary find all strategy to get things working.
- Element element = lookupLocalField(name);
+ // Match resolve order in Resolver.visitMethodInvocation
+ Element element = lookupLocalMethod(name);
if (element != null) {
return element;
}
- element = lookupLocalMethod(name);
+ element = lookupLocalField(name);
if (element != null) {
return element;
}
@@ -266,21 +268,31 @@ class ClassElementImplementation extends AbstractElement implements ClassElement
@Override
public Element lookupLocalElement(String name) {
- return members.get(name);
+ Iterator<Element> iterator = members.get(name).iterator();
+ if (iterator.hasNext()) {
+ return iterator.next();
+ }
+ return null;
}
FieldElement lookupLocalField(String name) {
- Element element = lookupLocalElement(name);
- if (ElementKind.of(element).equals(ElementKind.FIELD)) {
- return (FieldElement) element;
+ Iterator<Element> iterator = members.get(name).iterator();
+ while (iterator.hasNext()) {
+ Element element = iterator.next();
+ if (ElementKind.of(element).equals(ElementKind.FIELD)) {
+ return (FieldElement) element;
+ }
}
return null;
}
MethodElement lookupLocalMethod(String name) {
- Element element = lookupLocalElement(name);
- if (ElementKind.of(element).equals(ElementKind.METHOD)) {
- return (MethodElement) element;
+ Iterator<Element> iterator = members.get(name).iterator();
+ while (iterator.hasNext()) {
+ Element element = iterator.next();
+ if (ElementKind.of(element).equals(ElementKind.METHOD)) {
+ return (MethodElement) element;
+ }
}
return null;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698