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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10899033: Issue 4792. Infer multi-assign types usin raw types and the least specific arguments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 1cae5a0c7edfc5adf1cc485d421f750dd336c20b..70558081555eb782e936c4809abe1c78bdaadfb9 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -1766,7 +1766,7 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertTrue(message.contains("'bool'"));
}
}
-
+
/**
* <p>
* http://code.google.com/p/dart/issues/detail?id=4394
@@ -2130,6 +2130,52 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * We should understand type with type arguments and choose the most generic version.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=4792
+ */
+ public void test_typesPropagation_multiAssign_withGenerics_type_type() throws Exception {
+ analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "f() {",
+ " var a = new List<String>();",
+ " var b = <Object>[];",
+ " if (true) {",
+ " a = <Object>[];",
+ " b = new List<String>();",
+ " }",
+ " var a1 = a;",
+ " var b1 = b;",
+ "}",
+ "");
+ assertInferredElementTypeString(testUnit, "a1", "List<Object>");
+ assertInferredElementTypeString(testUnit, "b1", "List<Object>");
+ }
+
+ /**
+ * Prefer specific type, not Dynamic type argument.
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=4792
+ */
+ public void test_typesPropagation_multiAssign_withGenerics_type_dynamic() throws Exception {
+ analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "f() {",
+ " var a = new List<String>();",
+ " var b = [];",
+ " if (true) {",
+ " a = [];",
+ " b = new List<String>();",
+ " }",
+ " var a1 = a;",
+ " var b1 = b;",
+ "}",
+ "");
+ assertInferredElementTypeString(testUnit, "a1", "List<String>");
+ assertInferredElementTypeString(testUnit, "b1", "List<String>");
+ }
+
+ /**
* When we can not identify type of assigned value we should keep "Dynamic" as type of variable.
*/
public void test_typesPropagation_assign_newUnknownType() throws Exception {
« no previous file with comments | « compiler/java/com/google/dart/compiler/type/Types.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698