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 a generic closure is correctly constructed. |
| 6 |
| 7 library generic_methods_closure_test; |
| 8 |
| 9 import "test_base.dart"; |
| 10 |
| 11 class A {} |
| 12 |
| 13 class I<T> {} |
| 14 |
| 15 class B extends I<B> {} |
| 16 |
| 17 void fun<T>(List<T> list) { |
| 18 var helper1 = <S>(List<S> list) { |
| 19 if (list.length > 0) { |
| 20 expectTrue(list[0] is S); |
| 21 } |
| 22 expectTrue(list is List<S>); |
| 23 expectTrue(list is List<T>); |
| 24 }; |
| 25 |
| 26 void helper2<S>(List<S> list) { |
| 27 if (list.length > 0) { |
| 28 expectTrue(list[0] is S); |
| 29 } |
| 30 expectTrue(list is List<S>); |
| 31 expectTrue(list is List<T>); |
| 32 } |
| 33 |
| 34 helper1<T>(list); |
| 35 helper2<T>(list); |
| 36 } |
| 37 |
| 38 main() { |
| 39 List<B> list = <B>[new B()]; |
| 40 fun<B>(list); |
| 41 } |
OLD | NEW |