OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test least upper bound through type checking of conditionals. | 5 // Test least upper bound through type checking of conditionals. |
6 | 6 |
7 class A { | 7 class A { |
8 var a; | 8 var a; |
9 } | 9 } |
| 10 |
10 class B { | 11 class B { |
11 var b; | 12 var b; |
12 } | 13 } |
| 14 |
13 class C extends B { | 15 class C extends B { |
14 var c; | 16 var c; |
15 } | 17 } |
| 18 |
16 class D extends B { | 19 class D extends B { |
17 var d; | 20 var d; |
18 } | 21 } |
19 | 22 |
20 class E<T> { | 23 class E<T> { |
21 T e; | 24 T e; |
22 | 25 |
23 E(this.e); | 26 E(this.e); |
24 } | 27 } |
| 28 |
25 class F<T> extends E<T> { | 29 class F<T> extends E<T> { |
26 T f; | 30 T f; |
27 | 31 |
28 F(T f) : this.f = f, super(f); | 32 F(T f) |
| 33 : this.f = f, |
| 34 super(f); |
29 } | 35 } |
30 | 36 |
31 void main() { | 37 void main() { |
32 testAB(new A(), new B()); | 38 testAB(new A(), new B()); |
33 testBC(new C(), new C()); | 39 testBC(new C(), new C()); |
34 testCD(new C(), new D()); | 40 testCD(new C(), new D()); |
35 testEE(new F<C>(new C()), new F<C>(new C())); | 41 testEE(new F<C>(new C()), new F<C>(new C())); |
36 testEF(new F<C>(new C()), new F<C>(new C())); | 42 testEF(new F<C>(new C()), new F<C>(new C())); |
37 } | 43 } |
38 | 44 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 F<C> r2 = false ? e : f; //# 28: ok | 99 F<C> r2 = false ? e : f; //# 28: ok |
94 try { | 100 try { |
95 A r3 = true ? e : f; //# 29: ok | 101 A r3 = true ? e : f; //# 29: ok |
96 B r4 = false ? e : f; //# 30: ok | 102 B r4 = false ? e : f; //# 30: ok |
97 } catch (e) { | 103 } catch (e) { |
98 // Type error in checked mode. | 104 // Type error in checked mode. |
99 } | 105 } |
100 var r5; | 106 var r5; |
101 r5 = (true ? e : f).e; //# 31: static type warning | 107 r5 = (true ? e : f).e; //# 31: static type warning |
102 r5 = (false ? e : f).f; //# 32: static type warning | 108 r5 = (false ? e : f).f; //# 32: static type warning |
103 } | 109 } |
OLD | NEW |