Chromium Code Reviews| 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 library generic_methods_unused_parameter_test; | |
| 6 | |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 typedef Fun = int Function(); | |
| 10 typedef FunReq = int Function(int); | |
| 11 typedef FunOpt = int Function([int]); | |
| 12 typedef FunReqOpt = int Function(int, [int]); | |
| 13 typedef FunNam = int Function({int p}); | |
| 14 typedef FunReqNam = int Function(int, {int p}); | |
| 15 | |
| 16 typedef FunTyp = int Function<T>(); | |
| 17 typedef FunTypReq = int Function<T>(int); | |
| 18 typedef FunTypOpt = int Function<T>([int]); | |
| 19 typedef FunTypReqOpt = int Function<T>(int, [int]); | |
| 20 typedef FunTypNam = int Function<T>({int p}); | |
| 21 typedef FunTypReqNam = int Function<T>(int, {int p}); | |
| 22 | |
| 23 int fun() {} | |
| 24 int funReq(int x) => x; | |
| 25 int funOpt([int y]) => y ?? 42; | |
| 26 int funReqOpt(int x, [int y]) => x; | |
| 27 int funNam({int p}) => p ?? 42; | |
| 28 int funReqNam(int x, {int p}) => x; | |
| 29 | |
| 30 int funTyp<T>() {} | |
| 31 int funTypReq<T>(int x) => x; | |
| 32 int funTypOpt<T>([int y]) => y ?? 42; | |
| 33 int funTypReqOpt<T>(int x, [int y]) => x; | |
| 34 int funTypNam<T>({int p}) => p ?? 42; | |
| 35 int funTypReqNam<T>(int x, {int p}) => x; | |
| 36 | |
| 37 main() { | |
| 38 Fun varFun = funTyp; | |
|
eernst
2017/03/09 14:55:03
Agreeing with Leaf, I'll assume that you meant to
Dmitry Stefantsov
2017/03/10 13:21:55
Yes, I put the wrong types in lines 39-43 here. Al
| |
| 39 Fun varFunReq = funTypReq; | |
|
Leaf
2017/03/09 05:51:19
I think the LHS types here are wrong. Presumably
Dmitry Stefantsov
2017/03/10 13:21:55
Yes, exactly.
| |
| 40 Fun varFunOpt = funTypOpt; | |
| 41 Fun varFunReqOpt = funTypReqOpt; | |
| 42 Fun varFunNam = funTypNam; | |
| 43 Fun varFunReqNam = funTypReqNam; | |
| 44 | |
| 45 Expect.isTrue(fun is Fun); | |
| 46 Expect.isTrue(fun is! FunTyp); | |
| 47 Expect.isTrue(funTyp is! Fun); | |
| 48 Expect.isTrue(funTyp is FunTyp); | |
| 49 Expect.isTrue(varFun is Fun); | |
| 50 Expect.isTrue(varFun is! FunTyp); | |
| 51 | |
| 52 Expect.isTrue(funReq is FunReq); | |
| 53 Expect.isTrue(funReq is! FunTypReq); | |
| 54 Expect.isTrue(funTypReq is! FunReq); | |
| 55 Expect.isTrue(funTypReq is FunTypReq); | |
| 56 Expect.isTrue(varFunReq is FunReq); | |
| 57 Expect.isTrue(varFunReq is! FunTypReq); | |
| 58 | |
| 59 Expect.isTrue(funOpt is FunOpt); | |
| 60 Expect.isTrue(funOpt is! FunTypOpt); | |
| 61 Expect.isTrue(funTypOpt is! FunOpt); | |
| 62 Expect.isTrue(funTypOpt is FunTypOpt); | |
| 63 Expect.isTrue(varFunOpt is FunOpt); | |
| 64 Expect.isTrue(varFunOpt is! FunTypOpt); | |
| 65 | |
| 66 Expect.isTrue(funReqOpt is FunReqOpt); | |
| 67 Expect.isTrue(funReqOpt is! FunTypReqOpt); | |
| 68 Expect.isTrue(funTypReqOpt is! FunReqOpt); | |
| 69 Expect.isTrue(funTypReqOpt is FunTypReqOpt); | |
| 70 Expect.isTrue(varFunReqOpt is FunReqOpt); | |
| 71 Expect.isTrue(varFunReqOpt is! FunTypReqOpt); | |
| 72 | |
| 73 Expect.isTrue(funNam is FunNam); | |
| 74 Expect.isTrue(funNam is! FunTypNam); | |
| 75 Expect.isTrue(funTypNam is! FunNam); | |
| 76 Expect.isTrue(funTypNam is FunTypNam); | |
| 77 Expect.isTrue(varFunNam is FunNam); | |
| 78 Expect.isTrue(varFunNam is! FunTypNam); | |
| 79 | |
| 80 Expect.isTrue(funReqNam is FunReqNam); | |
| 81 Expect.isTrue(funReqNam is! FunTypReqNam); | |
| 82 Expect.isTrue(funTypReqNam is! FunReqNam); | |
| 83 Expect.isTrue(funTypReqNam is FunTypReqNam); | |
| 84 Expect.isTrue(varFunReqNam is FunReqNam); | |
| 85 Expect.isTrue(varFunReqNam is! FunTypReqNam); | |
| 86 } | |
| OLD | NEW |