| 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 generic methods with unused parameters aren't treated as |
| 6 // non-generic methods, but can be specialized as such. |
| 7 |
| 8 library generic_methods_unused_parameter_test; |
| 9 |
| 10 import "package:expect/expect.dart"; |
| 11 |
| 12 typedef Fun = int Function(); |
| 13 typedef FunReq = int Function(int); |
| 14 typedef FunOpt = int Function([int]); |
| 15 typedef FunReqOpt = int Function(int, [int]); |
| 16 typedef FunNam = int Function({int p}); |
| 17 typedef FunReqNam = int Function(int, {int p}); |
| 18 |
| 19 typedef FunTyp = int Function<T>(); |
| 20 typedef FunTypReq = int Function<T>(int); |
| 21 typedef FunTypOpt = int Function<T>([int]); |
| 22 typedef FunTypReqOpt = int Function<T>(int, [int]); |
| 23 typedef FunTypNam = int Function<T>({int p}); |
| 24 typedef FunTypReqNam = int Function<T>(int, {int p}); |
| 25 |
| 26 int fun() {} |
| 27 int funReq(int x) => x; |
| 28 int funOpt([int y]) => y ?? 42; |
| 29 int funReqOpt(int x, [int y]) => x; |
| 30 int funNam({int p}) => p ?? 42; |
| 31 int funReqNam(int x, {int p}) => x; |
| 32 |
| 33 int funTyp<T>() {} |
| 34 int funTypReq<T>(int x) => x; |
| 35 int funTypOpt<T>([int y]) => y ?? 42; |
| 36 int funTypReqOpt<T>(int x, [int y]) => x; |
| 37 int funTypNam<T>({int p}) => p ?? 42; |
| 38 int funTypReqNam<T>(int x, {int p}) => x; |
| 39 |
| 40 main() { |
| 41 Fun varFun = funTyp; |
| 42 FunReq varFunReq = funTypReq; |
| 43 FunOpt varFunOpt = funTypOpt; |
| 44 FunReqOpt varFunReqOpt = funTypReqOpt; |
| 45 FunNam varFunNam = funTypNam; |
| 46 FunReqNam varFunReqNam = funTypReqNam; |
| 47 |
| 48 Expect.isTrue(fun is Fun); |
| 49 Expect.isTrue(fun is! FunTyp); |
| 50 Expect.isTrue(funTyp is! Fun); |
| 51 Expect.isTrue(funTyp is FunTyp); |
| 52 Expect.isTrue(varFun is Fun); |
| 53 Expect.isTrue(varFun is! FunTyp); |
| 54 |
| 55 Expect.isTrue(funReq is FunReq); |
| 56 Expect.isTrue(funReq is! FunTypReq); |
| 57 Expect.isTrue(funTypReq is! FunReq); |
| 58 Expect.isTrue(funTypReq is FunTypReq); |
| 59 Expect.isTrue(varFunReq is FunReq); |
| 60 Expect.isTrue(varFunReq is! FunTypReq); |
| 61 |
| 62 Expect.isTrue(funOpt is FunOpt); |
| 63 Expect.isTrue(funOpt is! FunTypOpt); |
| 64 Expect.isTrue(funTypOpt is! FunOpt); |
| 65 Expect.isTrue(funTypOpt is FunTypOpt); |
| 66 Expect.isTrue(varFunOpt is FunOpt); |
| 67 Expect.isTrue(varFunOpt is! FunTypOpt); |
| 68 |
| 69 Expect.isTrue(funReqOpt is FunReqOpt); |
| 70 Expect.isTrue(funReqOpt is! FunTypReqOpt); |
| 71 Expect.isTrue(funTypReqOpt is! FunReqOpt); |
| 72 Expect.isTrue(funTypReqOpt is FunTypReqOpt); |
| 73 Expect.isTrue(varFunReqOpt is FunReqOpt); |
| 74 Expect.isTrue(varFunReqOpt is! FunTypReqOpt); |
| 75 |
| 76 Expect.isTrue(funNam is FunNam); |
| 77 Expect.isTrue(funNam is! FunTypNam); |
| 78 Expect.isTrue(funTypNam is! FunNam); |
| 79 Expect.isTrue(funTypNam is FunTypNam); |
| 80 Expect.isTrue(varFunNam is FunNam); |
| 81 Expect.isTrue(varFunNam is! FunTypNam); |
| 82 |
| 83 Expect.isTrue(funReqNam is FunReqNam); |
| 84 Expect.isTrue(funReqNam is! FunTypReqNam); |
| 85 Expect.isTrue(funTypReqNam is! FunReqNam); |
| 86 Expect.isTrue(funTypReqNam is FunTypReqNam); |
| 87 Expect.isTrue(varFunReqNam is FunReqNam); |
| 88 Expect.isTrue(varFunReqNam is! FunTypReqNam); |
| 89 } |
| OLD | NEW |