OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 // Test that F-bounded quantification works for generic methods, and that types |
| 6 // that are passed to generic methods in dynamic calls are checked for being |
| 7 // recursively defined. An exception should be thrown if the type doesn't meet |
| 8 // the expectation. |
| 9 |
| 10 library generic_methods_recursive_bound_error_test; |
| 11 |
| 12 import "test_base.dart"; |
| 13 |
| 14 abstract class I<T> { |
| 15 bool fun(T x); |
| 16 } |
| 17 |
| 18 void foo<T extends I<T>>(List<T> a) { |
| 19 if (a.length > 1) { |
| 20 a[0].fun(a[1]); |
| 21 } |
| 22 } |
| 23 |
| 24 class C implements I<C> { |
| 25 bool fun(C c) => true; |
| 26 } |
| 27 |
| 28 main() { |
| 29 dynamic bar = foo; |
| 30 List<int> list = <int>[4, 2]; |
| 31 // The type int does not extend I<int>. |
| 32 expectThrows(() => bar<int>(list), (e) => e is TypeError); |
| 33 } |
OLD | NEW |