| 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 // Tests self referencing types. | 5 // Tests self referencing types. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 class Base<T> { | 9 class Base<T> { |
| 10 get t => T; | 10 get t => T; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // Derived1<U> and Derived2<V> are contractive. | 22 // Derived1<U> and Derived2<V> are contractive. |
| 23 class Derived1<U> extends Base<Derived2<U>> {} /// 03: ok | 23 class Derived1<U> extends Base<Derived2<U>> {} /// 03: ok |
| 24 class Derived2<V> extends Base<Derived1<V>> {} /// 03: ok | 24 class Derived2<V> extends Base<Derived1<V>> {} /// 03: ok |
| 25 | 25 |
| 26 // Derived1<U> and Derived2<V> are non-contractive. | 26 // Derived1<U> and Derived2<V> are non-contractive. |
| 27 class Derived1<U> extends Base<Derived2<U>> {} /// 04: ok | 27 class Derived1<U> extends Base<Derived2<U>> {} /// 04: ok |
| 28 class Derived2<V> extends Base<Derived1<Derived2<V>>> {} /// 04: ok | 28 class Derived2<V> extends Base<Derived1<Derived2<V>>> {} /// 04: ok |
| 29 | 29 |
| 30 main() { | 30 main() { |
| 31 // In the tests below we test that we get "int" and "bool" when calling |
| 32 // toString() on the int and bool type respectively. This is not required |
| 33 // behavior. However, we want to keep the original names for the most common |
| 34 // core types so we make sure to handle these specifically in the compiler. |
| 35 |
| 31 var d; | 36 var d; |
| 32 d = new Derived(); /// 00: continued | 37 d = new Derived(); /// 00: continued |
| 33 Expect.equals("Derived", d.t.toString()); /// 00: continued | 38 Expect.equals("Derived", d.t.toString()); /// 00: continued |
| 34 d = new Derived<bool>(); /// 00: continued | 39 d = new Derived<bool>(); /// 00: continued |
| 35 Expect.equals("Derived<bool>", d.t.toString()); /// 00: continued | 40 Expect.equals("Derived<bool>", d.t.toString()); /// 00: continued |
| 36 d = new Derived<Derived>(); /// 00: continued | 41 d = new Derived<Derived>(); /// 00: continued |
| 37 Expect.equals("Derived<Derived>", d.t.toString()); /// 00: continued | 42 Expect.equals("Derived<Derived>", d.t.toString()); /// 00: continued |
| 38 | 43 |
| 39 d = new Derived(); /// 01: continued | 44 d = new Derived(); /// 01: continued |
| 45 |
| 40 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued | 46 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued |
| 41 d = new Derived<bool>(); /// 01: continued | 47 d = new Derived<bool>(); /// 01: continued |
| 42 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued | 48 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued |
| 43 d = new Derived<Derived>(); /// 01: continued | 49 d = new Derived<Derived>(); /// 01: continued |
| 44 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued | 50 Expect.equals("Derived<Derived<int>>", d.t.toString()); /// 01: continued |
| 45 | 51 |
| 46 d = new Derived(); /// 02: continued | 52 d = new Derived(); /// 02: continued |
| 47 Expect.equals("Derived<Derived>", d.t.toString()); /// 02: continued | 53 Expect.equals("Derived<Derived>", d.t.toString()); /// 02: continued |
| 48 d = new Derived<bool>(); /// 02: continued | 54 d = new Derived<bool>(); /// 02: continued |
| 49 Expect.equals("Derived<Derived<bool>>", d.t.toString()); /// 02: continued | 55 Expect.equals("Derived<Derived<bool>>", d.t.toString()); /// 02: continued |
| 50 d = new Derived<Derived>(); /// 02: continued | 56 d = new Derived<Derived>(); /// 02: continued |
| 51 Expect.equals("Derived<Derived<Derived>>", d.t.toString()); /// 02: continued | 57 Expect.equals("Derived<Derived<Derived>>", d.t.toString()); /// 02: continued |
| 52 | 58 |
| 53 d = new Derived1(); /// 03: continued | 59 d = new Derived1(); /// 03: continued |
| 54 Expect.equals("Derived2", d.t.toString()); /// 03: continued | 60 Expect.equals("Derived2", d.t.toString()); /// 03: continued |
| 55 d = new Derived2(); /// 03: continued | 61 d = new Derived2(); /// 03: continued |
| 56 Expect.equals("Derived1", d.t.toString()); /// 03: continued | 62 Expect.equals("Derived1", d.t.toString()); /// 03: continued |
| 57 d = new Derived2<Derived1<int>>(); /// 03: continued | 63 d = new Derived2<Derived1<int>>(); /// 03: continued |
| 58 Expect.equals("Derived1<Derived1<int>>", d.t.toString()); /// 03: continued | 64 Expect.equals("Derived1<Derived1<int>>", d.t.toString()); /// 03: continued |
| 59 | 65 |
| 60 d = new Derived1(); /// 04: continued | 66 d = new Derived1(); /// 04: continued |
| 61 Expect.equals("Derived2", d.t.toString()); /// 04: continued | 67 Expect.equals("Derived2", d.t.toString()); /// 04: continued |
| 62 d = new Derived2(); /// 04: continued | 68 d = new Derived2(); /// 04: continued |
| 63 Expect.equals("Derived1<Derived2>", d.t.toString()); /// 04: continued | 69 Expect.equals("Derived1<Derived2>", d.t.toString()); /// 04: continued |
| 64 d = new Derived2<Derived1<int>>(); /// 04: continued | 70 d = new Derived2<Derived1<int>>(); /// 04: continued |
| 65 Expect.equals("Derived1<Derived2<Derived1<int>>>", d.t.toString()); /// 04: c
ontinued | 71 Expect.equals("Derived1<Derived2<Derived1<int>>>", d.t.toString()); /// 04: c
ontinued |
| 66 } | 72 } |
| OLD | NEW |