| 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 "package:expect/expect.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 Expect.isTrue(list[0] is S); | |
| 21 } | |
| 22 Expect.isTrue(list is List<S>); | |
| 23 Expect.isTrue(list is List<T>); | |
| 24 }; | |
| 25 | |
| 26 void helper2<S>(List<S> list) { | |
| 27 if (list.length > 0) { | |
| 28 Expect.isTrue(list[0] is S); | |
| 29 } | |
| 30 Expect.isTrue(list is List<S>); | |
| 31 Expect.isTrue(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 |