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

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

Issue 8633015: Allow initializing a field in a superclass in a const constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes to lookupField Created 9 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
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/Elements.java » ('j') | 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 3e6b2ae5cdd577acd1b726919851b33d9d09dd59..8f730ba3f4c17af28ccebfaf0ffa2727b942e20a 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
@@ -268,6 +268,33 @@ class ClassElementImplementation extends AbstractElement implements ClassElement
return null;
}
+ /**
+ * Looks through all the fields in this class and its supertypes. Look through supertypes
+ * first, so that we can use this method to find conflicts.
+ */
+ FieldElement lookupField(String name) {
+ // Look through super classes
+ try {
+ if (!isInterface()) {
+ for (InterfaceType type : getAllSupertypes()) {
+ if (!type.getElement().isInterface()) {
+ InterfaceType.Member member = type.lookupMember(name);
+ if (member != null) {
+ FieldElement fieldElement = (FieldElement)member.getElement();
+ if (ElementKind.of(fieldElement).equals(ElementKind.FIELD) &&
+ !fieldElement.getModifiers().isAbstract()) {
+ return (FieldElement) member.getElement();
+ }
+ }
+ }
+ }
+ }
+ } catch (CyclicDeclarationException ignored) {
+ } catch (DuplicatedInterfaceException ignored) {
+ }
+ return lookupLocalField(name);
+ }
+
MethodElement lookupLocalMethod(String name) {
Element element = lookupLocalElement(name);
if (ElementKind.of(element).equals(ElementKind.METHOD)) {
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/resolver/Elements.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698