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

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

Issue 10459012: Issue 3223. Don't warn about types compatibility is one of the types was inferred (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 5b76ac8d5c3e2b1b49af890c3ef50a4f2123c6de..22d5d57907098358029514a75981a02a9d2741ba 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -535,7 +535,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
if (arg1 instanceof DartIdentifier && arg1.getElement() instanceof VariableElement
&& arg2 instanceof DartTypeExpression) {
VariableElement variableElement = (VariableElement) arg1.getElement();
- variableRestorer.setType(variableElement, arg2.getType());
+ Type isType = arg2.getType();
+ Type varType = InferredType.Helper.make(isType);
+ variableRestorer.setType(variableElement, varType);
}
}
// visit && expressions
@@ -614,10 +616,16 @@ public class TypeAnalyzer implements DartCompilationPhase {
private boolean checkAssignable(DartNode node, Type t, Type s) {
t.getClass(); // Null check.
s.getClass(); // Null check.
+ // ignore inferred types, treat them as Dynamic
+ if (t instanceof InferredType || s instanceof InferredType) {
+ return true;
+ }
+ // do check and report error
if (!types.isAssignable(t, s)) {
typeError(node, TypeErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE, s, t);
return false;
}
+ // OK
return true;
}
@@ -1909,7 +1917,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
if (value != null) {
Type valueType = value.getType();
if (TypeKind.of(valueType) != TypeKind.DYNAMIC) {
- Elements.setType(element, valueType);
+ Type varType = InferredType.Helper.make(valueType);
+ Elements.setType(element, varType);
Elements.setTypeInferred(element, true);
propagetedTypeVariables.add(element);
}

Powered by Google App Engine
This is Rietveld 408576698