OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Test for F-Bounded Quantification. | 7 // Test for F-Bounded Quantification. |
8 | 8 |
9 class FBound<F extends FBound<F>> {} | 9 class FBound<F extends FBound<F>> {} |
10 | 10 |
11 class Bar extends FBound<Bar> {} | 11 class Bar extends FBound<Bar> {} |
12 | 12 |
13 class SubBar extends Bar {} | 13 class SubBar extends Bar {} |
14 | 14 |
15 class Baz<T> extends FBound<Baz<T>> {} | 15 class Baz<T> extends FBound<Baz<T>> {} |
16 | 16 |
17 class SubBaz<T> extends Baz<T> {} | 17 class SubBaz<T> extends Baz<T> {} |
18 | 18 |
19 | |
20 isCheckedMode() { | 19 isCheckedMode() { |
21 try { | 20 try { |
22 var i = 1; | 21 var i = 1; |
23 String s = i; | 22 String s = i; |
24 return false; | 23 return false; |
25 } catch (e) { | 24 } catch (e) { |
26 return true; | 25 return true; |
27 } | 26 } |
28 } | 27 } |
29 | 28 |
(...skipping 14 matching lines...) Expand all Loading... |
44 bool got_type_error = false; | 43 bool got_type_error = false; |
45 try { | 44 try { |
46 FBound<SubBaz<Bar>> fsb = new FBound<SubBaz<Bar>>(); // //# 02: static typ
e warning | 45 FBound<SubBaz<Bar>> fsb = new FBound<SubBaz<Bar>>(); // //# 02: static typ
e warning |
47 } on TypeError catch (error) { | 46 } on TypeError catch (error) { |
48 got_type_error = true; | 47 got_type_error = true; |
49 } | 48 } |
50 // Type error in checked mode only. | 49 // Type error in checked mode only. |
51 Expect.isTrue(got_type_error == isCheckedMode()); // //# 02: continued | 50 Expect.isTrue(got_type_error == isCheckedMode()); // //# 02: continued |
52 } | 51 } |
53 } | 52 } |
OLD | NEW |