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

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

Issue 9188004: Issue 1091: Static type warning for setters with non-void return types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Language multitest 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
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 4b491d15756f1d97bedad8e20192abca4df97b17..c9761333d2a33ed23b0db34c9bfc79ffed9ce477 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -996,8 +996,14 @@ public class TypeAnalyzer implements DartCompilationPhase {
@Override
public Type visitMethodDefinition(DartMethodDefinition node) {
MethodElement methodElement = node.getSymbol();
- if (methodElement.getModifiers().isFactory()) {
+ Modifiers modifiers = methodElement.getModifiers();
+ if (modifiers.isFactory()) {
analyzeFactory(node.getName(), (ConstructorElement) methodElement);
+ } else if (modifiers.isSetter()) {
+ DartTypeNode returnType = node.getFunction().getReturnTypeNode();
+ if (returnType != null && returnType.getType() != voidType) {
+ typeError(returnType, TypeErrorCode.SETTER_RETURN_TYPE, methodElement.getName());
+ }
}
return typeAsVoid(node);
}

Powered by Google App Engine
This is Rietveld 408576698