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 for F-Bounded Quantification. | 5 // Test for F-Bounded Quantification. |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 class A<T extends B<T>> { | 9 class A<T extends B<T>> {} |
10 } | |
11 | 10 |
12 class B<T extends A<T>> { | 11 class B<T extends A<T>> {} |
13 } | |
14 | 12 |
15 isCheckedMode() { | 13 isCheckedMode() { |
16 try { | 14 try { |
17 var i = 1; | 15 var i = 1; |
18 String s = i; | 16 String s = i; |
19 return false; | 17 return false; |
20 } catch (e) { | 18 } catch (e) { |
21 return true; | 19 return true; |
22 } | 20 } |
23 } | 21 } |
24 | 22 |
25 main() { | 23 main() { |
26 bool got_type_error = false; | 24 bool got_type_error = false; |
27 try { | 25 try { |
28 // Getting "int" when calling toString() on the int type is not required. | 26 // Getting "int" when calling toString() on the int type is not required. |
29 // However, we want to keep the original names for the most common core | 27 // However, we want to keep the original names for the most common core |
30 // types so we make sure to handle these specifically in the compiler. | 28 // types so we make sure to handle these specifically in the compiler. |
31 Expect.equals("A<B<int>>", new A<B<int>>().runtimeType.toString()); | 29 Expect.equals("A<B<int>>", new A<B<int>>().runtimeType.toString()); |
32 } on TypeError catch (error) { | 30 } on TypeError catch (error) { |
33 got_type_error = true; | 31 got_type_error = true; |
34 } | 32 } |
35 // Type error expected in checked mode only. | 33 // Type error expected in checked mode only. |
36 Expect.isTrue(got_type_error == isCheckedMode()); | 34 Expect.isTrue(got_type_error == isCheckedMode()); |
37 } | 35 } |
38 | |
OLD | NEW |