| 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 torn off method of a generic class is not a generic method, | |
| 6 // and that it is correctly specialized. | |
| 7 | |
| 8 library generic_methods_generic_class_tearoff_test; | |
| 9 | |
| 10 import "package:expect/expect.dart"; | |
| 11 | |
| 12 class A<T> { | |
| 13 T fun(T t) => t; | |
| 14 } | |
| 15 | |
| 16 typedef Int2Int = int Function(int); | |
| 17 typedef String2String = String Function(String); | |
| 18 typedef Object2Object = Object Function(Object); | |
| 19 typedef GenericMethod = T Function<T>(T); | |
| 20 | |
| 21 main() { | |
| 22 A<int> x = new A<int>(); | |
| 23 var f = x.fun; // The type of f should be 'int Function(Object)'. | |
| 24 A<String> y = new A<String>(); | |
| 25 var g = y.fun; // The type of g should be 'String Function(Object)'. | |
| 26 A z = new A(); | |
| 27 var h = z.fun; // The type of h should be 'dynamic Function(Object)'. | |
| 28 | |
| 29 Expect.isTrue(f is Int2Int); | |
| 30 Expect.isTrue(f is! String2String); | |
| 31 Expect.isTrue(f is Object2Object); | |
| 32 Expect.isTrue(f is! GenericMethod); | |
| 33 | |
| 34 Expect.isTrue(g is! Int2Int); | |
| 35 Expect.isTrue(g is String2String); | |
| 36 Expect.isTrue(g is Object2Object); | |
| 37 Expect.isTrue(g is! GenericMethod); | |
| 38 | |
| 39 Expect.isTrue(h is! Int2Int); | |
| 40 Expect.isTrue(h is! String2String); | |
| 41 Expect.isTrue(h is Object2Object); | |
| 42 Expect.isTrue(h is! GenericMethod); | |
| 43 } | |
| OLD | NEW |