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

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

Issue 11896057: Issue 7605. Check separately getters and setter implementation when check for abstratc members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index f244fad5c4fce5840497893743d0d6a0626c3ba2..9acbd6c705ffee74d8822ac937df90db66953fa5 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -1614,7 +1614,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
if (!node.getModifiers().isAbstract() && !unimplementedMembers.isEmpty() &&
(reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(type))) {
StringBuilder sb = getUnimplementedMembersMessage(element, unimplementedMembers);
- onError(node.getName(), TypeErrorCode.CONTRETE_CLASS_WITH_UNIMPLEMENTED_MEMBERS,
+ onError(node.getName(), TypeErrorCode.CONCRETE_CLASS_WITH_UNIMPLEMENTED_MEMBERS,
node.getName(), sb.toString());
}
}
@@ -3221,16 +3221,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
while (supertype != null) {
ClassElement superclass = supertype.getElement();
for (Element member : superclass.getMembers()) {
- String name = member.getName();
- if (!Elements.isAbstractElement(member)) {
- superMembers.removeAll(name);
- }
- if (member instanceof FieldElement) {
- FieldElement field = (FieldElement) member;
- if (field.getSetter() != null) {
- superMembers.removeAll("setter " + name);
- }
- }
+ removeSuperMemberIfNotAbstract(member);
}
supertype = supertype.getElement().getSupertype();
}
@@ -3241,16 +3232,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
for (InterfaceType mixType : currentClass.getElement().getMixins()) {
ClassElement mixElement = mixType.getElement();
for (Element member : mixElement.getMembers()) {
- String name = member.getName();
- if (!Elements.isAbstractElement(member)) {
- superMembers.removeAll(name);
- }
- if (member instanceof FieldElement) {
- FieldElement field = (FieldElement) member;
- if (field.getSetter() != null) {
- superMembers.removeAll("setter " + name);
- }
- }
+ removeSuperMemberIfNotAbstract(member);
}
}
@@ -3274,7 +3256,17 @@ public class TypeAnalyzer implements DartCompilationPhase {
// add abstract members of current class
for (Element member : currentClass.getElement().getMembers()) {
- if (Elements.isAbstractElement(member)) {
+ if (ElementKind.of(member) == ElementKind.FIELD && member.getModifiers().isAbstractField()) {
+ FieldElement field = (FieldElement) member;
+ MethodElement getter = field.getGetter();
+ MethodElement setter = field.getSetter();
+ if (getter != null && Elements.isAbstractElement(getter)) {
+ unimplementedElements.add(getter);
+ }
+ if (setter != null && Elements.isAbstractElement(setter)) {
+ unimplementedElements.add(setter);
+ }
+ } else if (Elements.isAbstractElement(member)) {
unimplementedElements.add(member);
}
}
@@ -3282,6 +3274,27 @@ public class TypeAnalyzer implements DartCompilationPhase {
return null;
}
+ private void removeSuperMemberIfNotAbstract(Element member) {
+ String name = member.getName();
+ if (ElementKind.of(member) == ElementKind.FIELD && member.getModifiers().isAbstractField()) {
+ FieldElement field = (FieldElement) member;
+ MethodElement getter = field.getGetter();
+ MethodElement setter = field.getSetter();
+ if (getter != null && !Elements.isAbstractElement(getter)) {
+ superMembers.removeAll(name);
+ }
+ if (setter != null && !Elements.isAbstractElement(setter)) {
+ if (!name.startsWith("setter ")) {
+ superMembers.removeAll("setter " + name);
+ } else {
+ superMembers.removeAll(name);
+ }
+ }
+ } else if (!Elements.isAbstractElement(member)) {
+ superMembers.removeAll(name);
+ }
+ }
+
@Override
public Void visitFieldDefinition(DartFieldDefinition node) {
this.visit(node.getFields());

Powered by Google App Engine
This is Rietveld 408576698