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

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

Issue 12208101: Getter and setter methods can share name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/Context.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/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);
+ }
}
}
« no previous file with comments | « no previous file | editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/Context.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698