| 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. |
| 8 |
| 9 library generic_methods_recursive_bound_test; |
| 10 |
| 11 import "package:expect/expect.dart"; |
| 12 |
| 13 abstract class I<T> { |
| 14 bool fun(T x); |
| 15 } |
| 16 |
| 17 void foo<T extends I<T>>(List<T> a) { |
| 18 if (a.length > 1) { |
| 19 a[0].fun(a[1]); |
| 20 } |
| 21 } |
| 22 |
| 23 class C implements I<C> { |
| 24 bool fun(C c) => true; |
| 25 } |
| 26 |
| 27 main() { |
| 28 foo<C>(<C>[new C(), new C()]); /// 01: ok |
| 29 |
| 30 dynamic bar = foo; |
| 31 List<int> list2 = <int>[4, 2]; |
| 32 // The type int does not extend I<int>. |
| 33 foo<int>(list2); /// 02: compile-time error |
| 34 bar<int>(list2); /// 03: runtime error |
| 35 } |
| OLD | NEW |