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 fbeb242972265811a85b15711ee41f74dca8848d..743577d3be6f48ae53c49c01fb75b91f9e362cb1 100644 |
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java |
@@ -1016,8 +1016,8 @@ public class TypeAnalyzer implements DartCompilationPhase { |
setVariableElementType(variable, mergedType, mergedTypeQuality); |
} |
} |
- |
- private boolean checkAssignable(DartNode node, Type t, Type s) { |
+ |
+ private boolean isAssignable(Type t, Type s) { |
t.getClass(); // Null check. |
s.getClass(); // Null check. |
// ignore inferred types, treat them as Dynamic |
@@ -1026,15 +1026,22 @@ public class TypeAnalyzer implements DartCompilationPhase { |
return true; |
} |
} |
- // do check and report error |
+ // do check |
if (!types.isAssignable(t, s)) { |
Brian Wilkerson
2012/12/19 21:23:40
I believe that 1029 - 1034 could be replaced by "r
scheglov
2012/12/20 00:59:44
Done.
|
+ return false; |
+ } |
+ // OK |
+ return true; |
+ } |
+ |
+ private boolean checkAssignable(DartNode node, Type t, Type s) { |
+ if (!isAssignable(t, s)) { |
TypeErrorCode errorCode = TypeQuality.isInferred(t) || TypeQuality.isInferred(s) |
? TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE_INFERRED |
- : TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE; |
+ : TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE; |
typeError(node, errorCode, s, t); |
return false; |
} |
- // OK |
return true; |
} |
@@ -2809,7 +2816,7 @@ public class TypeAnalyzer implements DartCompilationPhase { |
case DYNAMIC: |
return type; |
default: |
- if (types.isAssignable(functionType, type)) { |
+ if (isAssignable(functionType, type)) { |
// A subtype of interface Function. |
return dynamicType; |
} else if (name == null || currentClass == null) { |