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

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

Issue 10837237: Issue 4383. Calling field without setter should generate problem (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use same text for error as for warning Created 8 years, 4 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 e42b75fbd84ee682dd6a43f1bf6905ba2650ddec..c74bae1cee711412492bd9c42de7c7f90aa5af04 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -915,12 +915,13 @@ public class TypeAnalyzer implements DartCompilationPhase {
return Types.asFunctionType((FunctionAliasType) member.getType());
default:
// target.field() as Function invocation.
- if (types.isAssignable(functionType, field.getType())) {
- return dynamicType;
+ if (Elements.isFieldWithGetter(field)) {
+ Type fieldType = field.getType();
+ if (!types.isAssignable(functionType, fieldType)) {
+ onError(diagnosticNode, TypeErrorCode.NOT_A_FUNCTION_TYPE, fieldType);
+ }
}
- // "field" is not Function, so bad structure.
- return typeError(diagnosticNode, TypeErrorCode.USE_ASSIGNMENT_ON_SETTER,
- name, receiver);
+ return dynamicType;
}
}
default:
@@ -1283,6 +1284,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
nameNode.setElement(element);
}
}
+ if (Elements.isAbstractFieldWithoutGetter(element)) {
+ onError(nameNode, TypeErrorCode.USE_ASSIGNMENT_ON_SETTER, name);
+ }
checkDeprecated(nameNode, nameNode.getElement());
FunctionType methodType = getMethodType(receiver, member, name, nameNode);
Type returnType = checkInvocation(node, nameNode, name, methodType);

Powered by Google App Engine
This is Rietveld 408576698