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

Unified Diff: tests/language/type_promotion_logical_and_test.dart

Issue 26232003: Support type promotion in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to latest spec change 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: tests/language/type_promotion_logical_and_test.dart
diff --git a/tests/language/type_promotion_logical_and_test.dart b/tests/language/type_promotion_logical_and_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..92a4758a02b8c9e9ad27b5ab9500a2ee6ef0d167
--- /dev/null
+++ b/tests/language/type_promotion_logical_and_test.dart
@@ -0,0 +1,41 @@
+// 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.
+
+// Test type promotion of locals potentially mutated.
+
+class A {
+ var a = true;
+}
+class B extends A {
+ var b = true;
+}
+class C extends B {
+ var c = true;
+}
+class D extends A {
+ var d = true;
+}
+class E implements C, D {
+ var a = true;
+ var b = true;
+ var c = true;
+ var d = true;
+}
+
+void main() {
+ A a = new E();
+ var b;
+ if (a is D && ((a = new D()) != null)) {
+ b = a.d; /// 01: static type warning
+ }
+ if (a is D && (b = a.d)) {
+ b = a.d; /// 02: static type warning
+ a = null;
+ }
+ if (f(a = null) && a is D) {
+ b = a.d;
+ }
+}
+
+bool f(x) => true;
« no previous file with comments | « tests/language/type_promotion_local_test.dart ('k') | tests/language/type_promotion_more_specific_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698