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

Unified Diff: tests/compiler/dart2js/simple_inferrer_and_or_test.dart

Issue 182373002: Fix bad type-inferrence for logical expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use lhs of &&. Created 6 years, 10 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: tests/compiler/dart2js/simple_inferrer_and_or_test.dart
diff --git a/tests/compiler/dart2js/simple_inferrer_and_or_test.dart b/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
index 97531a6846a85da489047542b61f7fc5d85a6667..dea4f693ed1a00ae15958aa8dc7fdf0754f1124c 100644
--- a/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_and_or_test.dart
@@ -45,6 +45,39 @@ returnDyn6() {
return a;
}
+returnDyn7b(x) => x;
+
+returnDyn7() {
+ var a = "foo";
+ if (a.length == 3) a = 52;
+ if ((a is int) || (a is String && true)) returnDyn7b(a);
+ return a;
+}
+
+returnDyn8(x) => x;
+
+test8() {
+ var a = "foo";
+ if (a.length == 3) a = 52;
+ if ((false && a is! String) || returnDyn8(a)) return a;
+}
+
+returnDyn9(x) => x;
+
+test9() {
+ var a = "foo";
+ if (a.length == 3) a = 52;
+ if (!(a is bool && a is bool)) returnDyn9(a);
+}
+
+returnString(x) => x;
+
+test10() {
+ var a = "foo";
+ if (a.length == 3) a = 52;
+ if (!(a is num) && a is String) returnString(a);
+}
+
main() {
returnDyn1();
returnDyn2();
@@ -52,6 +85,10 @@ main() {
returnDyn4();
returnDyn5();
returnDyn6();
+ returnDyn7();
+ test8();
+ test9();
+ test10();
}
""";
@@ -77,5 +114,10 @@ void main() {
checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable());
checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable());
checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable());
+ checkReturn('returnDyn7', subclassOfInterceptor);
+ checkReturn('returnDyn7b', subclassOfInterceptor);
+ checkReturn('returnDyn8', subclassOfInterceptor);
+ checkReturn('returnDyn9', subclassOfInterceptor);
+ checkReturn('returnString', compiler.typesTask.stringType);
}));
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart ('k') | tests/language/logical_expression2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698