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

Unified Diff: tests/language/type_promotion_multiple_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_multiple_test.dart
diff --git a/tests/language/type_promotion_multiple_test.dart b/tests/language/type_promotion_multiple_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f692916c722bdbe27bd6f4449e9d8ff0b4d13363
--- /dev/null
+++ b/tests/language/type_promotion_multiple_test.dart
@@ -0,0 +1,96 @@
+// 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.
+
+class A {
+ var a = "a";
+}
+class B extends A {
+ var b = "b";
+}
+class C extends B {
+ var c = "c";
+}
+class D extends A {
+ var d = "d";
+}
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ test(new E());
+}
+void test(A a1) {
+ A a2 = new E();
+ print(a1.a);
+ print(a1.b); /// 01: static type warning
+ print(a1.c); /// 02: static type warning
+ print(a1.d); /// 03: static type warning
+
+ print(a2.a);
+ print(a2.b); /// 04: static type warning
+ print(a2.c); /// 05: static type warning
+ print(a2.d); /// 06: static type warning
+
+ if (a1 is B && a2 is C) {
+ print(a1.a);
+ print(a1.b);
+ print(a1.c); /// 07: static type warning
+ print(a1.d); /// 08: static type warning
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+ print(a2.d); /// 09: static type warning
+
+ if (a1 is C && a2 is D) {
+ print(a1.a);
+ print(a1.b);
+ print(a1.c);
+ print(a1.d); /// 10: static type warning
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+ print(a2.d); /// 11: static type warning
+ }
+ }
+
+ var o1 = a1 is B && a2 is C ?
+ '${a1.a}'
+ '${a1.b}'
+ '${a1.c}' /// 12: static type warning
+ '${a1.d}' /// 13: static type warning
+ '${a2.a}'
+ '${a2.b}'
+ '${a2.c}'
+ '${a2.d}' /// 14: static type warning
+ :
+ '${a1.a}'
+ '${a1.b}' /// 15: static type warning
+ '${a1.c}' /// 16: static type warning
+ '${a1.d}' /// 17: static type warning
+ '${a2.a}'
+ '${a2.b}' /// 18: static type warning
+ '${a2.c}' /// 19: static type warning
+ '${a2.d}' /// 20: static type warning
+ ;
+
+ if (a2 is C && a1 is B && a1 is C && a2 is B && a2 is D) {
+ print(a1.a);
+ print(a1.b);
+ print(a1.c);
+ print(a1.d); /// 21: static type warning
+
+ print(a2.a);
+ print(a2.b);
+ print(a2.c);
+ print(a2.d); /// 22: static type warning
+ }
+}
« no previous file with comments | « tests/language/type_promotion_more_specific_test.dart ('k') | tests/language/type_promotion_parameter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698