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 a2d1272a750e04dea18a4ad7c5ed980583abb54b..cb153236ca96db7c2822d478bd91b711ecdcf5c3 100644 |
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
@@ -3449,13 +3449,43 @@ public class TypeAnalyzer implements DartCompilationPhase { |
superMember); |
} |
} |
- } else if (!types.isAssignable(superMember, member.getType())) { |
- typeError(errorTarget, |
- TypeErrorCode.CANNOT_OVERRIDE_TYPED_MEMBER, |
- name, |
- superElement.getEnclosingElement().getName(), |
- member.getType(), |
- superMember); |
+ } else { |
+ if (ElementKind.of(member) == ElementKind.FIELD |
+ && ElementKind.of(superElement) == ElementKind.FIELD) { |
+ FieldElement field = (FieldElement) member; |
+ FieldElement superField = (FieldElement) superElement; |
+ // |
+ MethodElement fGetter = field.getGetter(); |
+ MethodElement sGetter = superField.getGetter(); |
+ if (fGetter != null && sGetter != null) { |
+ checkOverride(errorTarget, fGetter, sGetter); |
+ } else if (fGetter != null && sGetter == null || fGetter == null && sGetter != null) { |
+ } else { |
+ if (!types.isAssignable(superMember, member.getType())) { |
+ typeError(errorTarget, TypeErrorCode.CANNOT_OVERRIDE_TYPED_MEMBER, name, |
+ superElement.getEnclosingElement().getName(), member.getType(), superMember); |
+ return; |
+ } |
+ } |
+ // |
+ MethodElement fSetter = field.getSetter(); |
+ MethodElement sSetter = superField.getSetter(); |
+ if (fSetter != null && sSetter != null) { |
+ checkOverride(errorTarget, fSetter, sSetter); |
+ } else if (fSetter != null && sSetter == null || fSetter == null && sSetter != null) { |
+ } else { |
+ if (!types.isAssignable(superMember, member.getType())) { |
+ typeError(errorTarget, TypeErrorCode.CANNOT_OVERRIDE_TYPED_MEMBER, name, |
+ superElement.getEnclosingElement().getName(), member.getType(), superMember); |
+ return; |
+ } |
+ } |
+ return; |
+ } |
+ if (!types.isAssignable(superMember, member.getType())) { |
+ typeError(errorTarget, TypeErrorCode.CANNOT_OVERRIDE_TYPED_MEMBER, name, |
+ superElement.getEnclosingElement().getName(), member.getType(), superMember); |
+ } |
} |
} |