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

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

Issue 11364032: Issue 6107. Infer cascade type when it is assigned to the element with know type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/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 445482faaae2cf37f35f3709c43bafc707290b5f..2a08cf14f47ef2b07bae20b2acc86ad3f3ce6c93 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -4340,6 +4340,93 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
}
/**
+ * There should be no problem reported, because assignment of "a" cascade to "b" with type "B"
+ * implicitly set type of "a" to "B".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=6107
+ */
+ public void test_cascade_inferType_varDeclaration() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "class B extends A {",
+ " bMethod() {}",
+ "}",
+ "main() {",
+ " A a = new B();",
+ " B b = a..bMethod();",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ }
+
+ /**
+ * There should be no problem reported, because assignment of "a" cascade to "b" with type "B"
+ * implicitly set type of "a" to "B".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=6107
+ */
+ public void test_cascade_inferType_varAssignment() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "class B extends A {",
+ " bMethod() {}",
+ "}",
+ "main() {",
+ " A a = new B();",
+ " B b = null;",
+ " b = a..bMethod();",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ }
+
+ /**
+ * We assign "a" to field "Holder.b" of type "B", so implicitly set type of "a" to "B".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=6107
+ */
+ public void test_cascade_inferType_fieldDeclaration() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Holder {",
+ " B b = getA()..bMethod();",
+ "}",
+ "class A {}",
+ "class B extends A {",
+ " bMethod() {}",
+ "}",
+ "A getA() => new B();",
+ "");
+ assertErrors(result.getErrors());
+ }
+
+ /**
+ * We assign "a" to field "Holder.b" of type "B", so implicitly set type of "a" to "B".
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=6107
+ */
+ public void test_cascade_inferType_fieldAssignment() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class Holder {",
+ " B b;",
+ "}",
+ "class A {}",
+ "class B extends A {",
+ " bMethod() {}",
+ "}",
+ "main() {",
+ " A a = new B();",
+ " Holder holder = new Holder();",
+ " holder.b = a..bMethod();",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ }
+
+ /**
* <p>
* http://code.google.com/p/dart/issues/detail?id=4315
*/

Powered by Google App Engine
This is Rietveld 408576698