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

Unified Diff: tests/language/type_propagation_test.dart

Issue 16295008: Fix type propagation bug by always narrowing types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/type_propagation_test.dart
===================================================================
--- tests/language/type_propagation_test.dart (revision 0)
+++ tests/language/type_propagation_test.dart (revision 0)
@@ -0,0 +1,43 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// dart2js used to have an infinite loop in its type propagation
+// algorithm due to types becoming broader instead of narrower.
+
+import "package:expect/expect.dart";
+
+class A {
+ resolveSend(node) {
+ if (node == null) {
+ return [new B()][0];
+ } else {
+ return [new B(), new A()][1];
+ }
+ }
+
+ visitSend(node) {
+ var target = resolveSend(node);
+
+ if (false) {
+ if (false) {
+ target = target.getter;
+ if (false) {
+ target = new Object();
+ }
+ }
+ }
+ return true ? target : null;
+ }
+}
+
+var a = 43;
+
+class B {
+ var getter = a == 42 ? new A() : null;
+}
+
+main() {
+ Expect.isTrue(new A().visitSend(new A()) is A);
+ Expect.isTrue(new A().visitSend(null) is B);
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698