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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java

Issue 38353003: Issue 13807. Support for function types promotion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
index 8407959cf98d8814ff58d122fc42aacbb4776cff..246f51726410afe0adab9ecc736af09bf2d3fabd 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
@@ -3031,6 +3031,52 @@ public class NonErrorResolverTest extends ResolverTestCase {
verify(source);
}
+ public void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() throws Exception {
+ Source source = addSource(createSource(//
+ "typedef FuncB(B b);",
+ "typedef FuncA(A a);",
+ "class A {}",
+ "class B {}",
+ "main(FuncA f) {",
+ " if (f is FuncB) {",
+ " f(new A());",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() throws Exception {
+ Source source = addSource(createSource(//
+ "typedef FuncDynToDyn(x);",
+ "typedef void FuncDynToVoid(x);",
+ "class A {}",
+ "main(FuncDynToDyn f) {",
+ " if (f is FuncDynToVoid) {",
+ " A a = f(null);",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_typePromotion_functionType_return_voidToDynamic() throws Exception {
+ Source source = addSource(createSource(//
+ "typedef FuncDynToDyn(x);",
+ "typedef void FuncDynToVoid(x);",
+ "class A {}",
+ "main(FuncDynToVoid f) {",
+ " if (f is FuncDynToDyn) {",
+ " A a = f(null);",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
public void test_typePromotion_if_accessedInClosure_noAssignment() throws Exception {
Source source = addSource(createSource(//
"callMe(f()) { f(); }",
@@ -3098,6 +3144,25 @@ public class NonErrorResolverTest extends ResolverTestCase {
verify(source);
}
+ public void test_typePromotion_if_is_and_subThenSuper() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " var a;",
+ "}",
+ "class B extends A {",
+ " var b;",
+ "}",
+ "main(Object p) {",
+ " if (p is B && p is A) {",
+ " p.a;",
+ " p.b;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
public void test_typePromotion_if_is_parenthesized() throws Exception {
Source source = addSource(createSource(//
"main(Object p) {",

Powered by Google App Engine
This is Rietveld 408576698