|
17 | 17 |
|
18 | 18 | package reflectx
|
19 | 19 |
|
20 |
| -import "reflect" |
| 20 | +import ( |
| 21 | + "fmt" |
| 22 | + "reflect" |
| 23 | +) |
21 | 24 |
|
22 | 25 | // Generated arity-specialized Func implementations to avoid runtime temporary
|
23 | 26 | // slices. Code that knows the arity can potentially avoid that overhead in
|
@@ -57,7 +60,7 @@ func (c *shimFunc0x0) Call0x0() {
|
57 | 60 |
|
58 | 61 | func ToFunc0x0(c Func) Func0x0 {
|
59 | 62 | if c.Type().NumIn() != 0 || c.Type().NumOut() != 0 {
|
60 |
| - panic("incompatible func type") |
| 63 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
61 | 64 | }
|
62 | 65 | if sc, ok := c.(Func0x0); ok {
|
63 | 66 | return sc
|
@@ -98,7 +101,7 @@ func (c *shimFunc0x1) Call0x1() interface{} {
|
98 | 101 |
|
99 | 102 | func ToFunc0x1(c Func) Func0x1 {
|
100 | 103 | if c.Type().NumIn() != 0 || c.Type().NumOut() != 1 {
|
101 |
| - panic("incompatible func type") |
| 104 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
102 | 105 | }
|
103 | 106 | if sc, ok := c.(Func0x1); ok {
|
104 | 107 | return sc
|
@@ -139,7 +142,7 @@ func (c *shimFunc0x2) Call0x2() (interface{}, interface{}) {
|
139 | 142 |
|
140 | 143 | func ToFunc0x2(c Func) Func0x2 {
|
141 | 144 | if c.Type().NumIn() != 0 || c.Type().NumOut() != 2 {
|
142 |
| - panic("incompatible func type") |
| 145 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
143 | 146 | }
|
144 | 147 | if sc, ok := c.(Func0x2); ok {
|
145 | 148 | return sc
|
@@ -180,7 +183,7 @@ func (c *shimFunc0x3) Call0x3() (interface{}, interface{}, interface{}) {
|
180 | 183 |
|
181 | 184 | func ToFunc0x3(c Func) Func0x3 {
|
182 | 185 | if c.Type().NumIn() != 0 || c.Type().NumOut() != 3 {
|
183 |
| - panic("incompatible func type") |
| 186 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
184 | 187 | }
|
185 | 188 | if sc, ok := c.(Func0x3); ok {
|
186 | 189 | return sc
|
@@ -221,7 +224,7 @@ func (c *shimFunc1x0) Call1x0(arg0 interface{}) {
|
221 | 224 |
|
222 | 225 | func ToFunc1x0(c Func) Func1x0 {
|
223 | 226 | if c.Type().NumIn() != 1 || c.Type().NumOut() != 0 {
|
224 |
| - panic("incompatible func type") |
| 227 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
225 | 228 | }
|
226 | 229 | if sc, ok := c.(Func1x0); ok {
|
227 | 230 | return sc
|
@@ -262,7 +265,7 @@ func (c *shimFunc1x1) Call1x1(arg0 interface{}) interface{} {
|
262 | 265 |
|
263 | 266 | func ToFunc1x1(c Func) Func1x1 {
|
264 | 267 | if c.Type().NumIn() != 1 || c.Type().NumOut() != 1 {
|
265 |
| - panic("incompatible func type") |
| 268 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
266 | 269 | }
|
267 | 270 | if sc, ok := c.(Func1x1); ok {
|
268 | 271 | return sc
|
@@ -303,7 +306,7 @@ func (c *shimFunc1x2) Call1x2(arg0 interface{}) (interface{}, interface{}) {
|
303 | 306 |
|
304 | 307 | func ToFunc1x2(c Func) Func1x2 {
|
305 | 308 | if c.Type().NumIn() != 1 || c.Type().NumOut() != 2 {
|
306 |
| - panic("incompatible func type") |
| 309 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
307 | 310 | }
|
308 | 311 | if sc, ok := c.(Func1x2); ok {
|
309 | 312 | return sc
|
@@ -344,7 +347,7 @@ func (c *shimFunc1x3) Call1x3(arg0 interface{}) (interface{}, interface{}, inter
|
344 | 347 |
|
345 | 348 | func ToFunc1x3(c Func) Func1x3 {
|
346 | 349 | if c.Type().NumIn() != 1 || c.Type().NumOut() != 3 {
|
347 |
| - panic("incompatible func type") |
| 350 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
348 | 351 | }
|
349 | 352 | if sc, ok := c.(Func1x3); ok {
|
350 | 353 | return sc
|
@@ -385,7 +388,7 @@ func (c *shimFunc2x0) Call2x0(arg0, arg1 interface{}) {
|
385 | 388 |
|
386 | 389 | func ToFunc2x0(c Func) Func2x0 {
|
387 | 390 | if c.Type().NumIn() != 2 || c.Type().NumOut() != 0 {
|
388 |
| - panic("incompatible func type") |
| 391 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 2 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
389 | 392 | }
|
390 | 393 | if sc, ok := c.(Func2x0); ok {
|
391 | 394 | return sc
|
@@ -426,7 +429,7 @@ func (c *shimFunc2x1) Call2x1(arg0, arg1 interface{}) interface{} {
|
426 | 429 |
|
427 | 430 | func ToFunc2x1(c Func) Func2x1 {
|
428 | 431 | if c.Type().NumIn() != 2 || c.Type().NumOut() != 1 {
|
429 |
| - panic("incompatible func type") |
| 432 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 2 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
430 | 433 | }
|
431 | 434 | if sc, ok := c.(Func2x1); ok {
|
432 | 435 | return sc
|
@@ -467,7 +470,7 @@ func (c *shimFunc2x2) Call2x2(arg0, arg1 interface{}) (interface{}, interface{})
|
467 | 470 |
|
468 | 471 | func ToFunc2x2(c Func) Func2x2 {
|
469 | 472 | if c.Type().NumIn() != 2 || c.Type().NumOut() != 2 {
|
470 |
| - panic("incompatible func type") |
| 473 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 2 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
471 | 474 | }
|
472 | 475 | if sc, ok := c.(Func2x2); ok {
|
473 | 476 | return sc
|
@@ -508,7 +511,7 @@ func (c *shimFunc2x3) Call2x3(arg0, arg1 interface{}) (interface{}, interface{},
|
508 | 511 |
|
509 | 512 | func ToFunc2x3(c Func) Func2x3 {
|
510 | 513 | if c.Type().NumIn() != 2 || c.Type().NumOut() != 3 {
|
511 |
| - panic("incompatible func type") |
| 514 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 2 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
512 | 515 | }
|
513 | 516 | if sc, ok := c.(Func2x3); ok {
|
514 | 517 | return sc
|
@@ -549,7 +552,7 @@ func (c *shimFunc3x0) Call3x0(arg0, arg1, arg2 interface{}) {
|
549 | 552 |
|
550 | 553 | func ToFunc3x0(c Func) Func3x0 {
|
551 | 554 | if c.Type().NumIn() != 3 || c.Type().NumOut() != 0 {
|
552 |
| - panic("incompatible func type") |
| 555 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 3 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
553 | 556 | }
|
554 | 557 | if sc, ok := c.(Func3x0); ok {
|
555 | 558 | return sc
|
@@ -590,7 +593,7 @@ func (c *shimFunc3x1) Call3x1(arg0, arg1, arg2 interface{}) interface{} {
|
590 | 593 |
|
591 | 594 | func ToFunc3x1(c Func) Func3x1 {
|
592 | 595 | if c.Type().NumIn() != 3 || c.Type().NumOut() != 1 {
|
593 |
| - panic("incompatible func type") |
| 596 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 3 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
594 | 597 | }
|
595 | 598 | if sc, ok := c.(Func3x1); ok {
|
596 | 599 | return sc
|
@@ -631,7 +634,7 @@ func (c *shimFunc3x2) Call3x2(arg0, arg1, arg2 interface{}) (interface{}, interf
|
631 | 634 |
|
632 | 635 | func ToFunc3x2(c Func) Func3x2 {
|
633 | 636 | if c.Type().NumIn() != 3 || c.Type().NumOut() != 2 {
|
634 |
| - panic("incompatible func type") |
| 637 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 3 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
635 | 638 | }
|
636 | 639 | if sc, ok := c.(Func3x2); ok {
|
637 | 640 | return sc
|
@@ -672,7 +675,7 @@ func (c *shimFunc3x3) Call3x3(arg0, arg1, arg2 interface{}) (interface{}, interf
|
672 | 675 |
|
673 | 676 | func ToFunc3x3(c Func) Func3x3 {
|
674 | 677 | if c.Type().NumIn() != 3 || c.Type().NumOut() != 3 {
|
675 |
| - panic("incompatible func type") |
| 678 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 3 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
676 | 679 | }
|
677 | 680 | if sc, ok := c.(Func3x3); ok {
|
678 | 681 | return sc
|
@@ -713,7 +716,7 @@ func (c *shimFunc4x0) Call4x0(arg0, arg1, arg2, arg3 interface{}) {
|
713 | 716 |
|
714 | 717 | func ToFunc4x0(c Func) Func4x0 {
|
715 | 718 | if c.Type().NumIn() != 4 || c.Type().NumOut() != 0 {
|
716 |
| - panic("incompatible func type") |
| 719 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 4 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
717 | 720 | }
|
718 | 721 | if sc, ok := c.(Func4x0); ok {
|
719 | 722 | return sc
|
@@ -754,7 +757,7 @@ func (c *shimFunc4x1) Call4x1(arg0, arg1, arg2, arg3 interface{}) interface{} {
|
754 | 757 |
|
755 | 758 | func ToFunc4x1(c Func) Func4x1 {
|
756 | 759 | if c.Type().NumIn() != 4 || c.Type().NumOut() != 1 {
|
757 |
| - panic("incompatible func type") |
| 760 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 4 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
758 | 761 | }
|
759 | 762 | if sc, ok := c.(Func4x1); ok {
|
760 | 763 | return sc
|
@@ -795,7 +798,7 @@ func (c *shimFunc4x2) Call4x2(arg0, arg1, arg2, arg3 interface{}) (interface{},
|
795 | 798 |
|
796 | 799 | func ToFunc4x2(c Func) Func4x2 {
|
797 | 800 | if c.Type().NumIn() != 4 || c.Type().NumOut() != 2 {
|
798 |
| - panic("incompatible func type") |
| 801 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 4 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
799 | 802 | }
|
800 | 803 | if sc, ok := c.(Func4x2); ok {
|
801 | 804 | return sc
|
@@ -836,7 +839,7 @@ func (c *shimFunc4x3) Call4x3(arg0, arg1, arg2, arg3 interface{}) (interface{},
|
836 | 839 |
|
837 | 840 | func ToFunc4x3(c Func) Func4x3 {
|
838 | 841 | if c.Type().NumIn() != 4 || c.Type().NumOut() != 3 {
|
839 |
| - panic("incompatible func type") |
| 842 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 4 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
840 | 843 | }
|
841 | 844 | if sc, ok := c.(Func4x3); ok {
|
842 | 845 | return sc
|
@@ -877,7 +880,7 @@ func (c *shimFunc5x0) Call5x0(arg0, arg1, arg2, arg3, arg4 interface{}) {
|
877 | 880 |
|
878 | 881 | func ToFunc5x0(c Func) Func5x0 {
|
879 | 882 | if c.Type().NumIn() != 5 || c.Type().NumOut() != 0 {
|
880 |
| - panic("incompatible func type") |
| 883 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
881 | 884 | }
|
882 | 885 | if sc, ok := c.(Func5x0); ok {
|
883 | 886 | return sc
|
@@ -918,7 +921,7 @@ func (c *shimFunc5x1) Call5x1(arg0, arg1, arg2, arg3, arg4 interface{}) interfac
|
918 | 921 |
|
919 | 922 | func ToFunc5x1(c Func) Func5x1 {
|
920 | 923 | if c.Type().NumIn() != 5 || c.Type().NumOut() != 1 {
|
921 |
| - panic("incompatible func type") |
| 924 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
922 | 925 | }
|
923 | 926 | if sc, ok := c.(Func5x1); ok {
|
924 | 927 | return sc
|
@@ -959,7 +962,7 @@ func (c *shimFunc5x2) Call5x2(arg0, arg1, arg2, arg3, arg4 interface{}) (interfa
|
959 | 962 |
|
960 | 963 | func ToFunc5x2(c Func) Func5x2 {
|
961 | 964 | if c.Type().NumIn() != 5 || c.Type().NumOut() != 2 {
|
962 |
| - panic("incompatible func type") |
| 965 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
963 | 966 | }
|
964 | 967 | if sc, ok := c.(Func5x2); ok {
|
965 | 968 | return sc
|
@@ -1000,7 +1003,7 @@ func (c *shimFunc5x3) Call5x3(arg0, arg1, arg2, arg3, arg4 interface{}) (interfa
|
1000 | 1003 |
|
1001 | 1004 | func ToFunc5x3(c Func) Func5x3 {
|
1002 | 1005 | if c.Type().NumIn() != 5 || c.Type().NumOut() != 3 {
|
1003 |
| - panic("incompatible func type") |
| 1006 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1004 | 1007 | }
|
1005 | 1008 | if sc, ok := c.(Func5x3); ok {
|
1006 | 1009 | return sc
|
@@ -1041,7 +1044,7 @@ func (c *shimFunc6x0) Call6x0(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) {
|
1041 | 1044 |
|
1042 | 1045 | func ToFunc6x0(c Func) Func6x0 {
|
1043 | 1046 | if c.Type().NumIn() != 6 || c.Type().NumOut() != 0 {
|
1044 |
| - panic("incompatible func type") |
| 1047 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1045 | 1048 | }
|
1046 | 1049 | if sc, ok := c.(Func6x0); ok {
|
1047 | 1050 | return sc
|
@@ -1082,7 +1085,7 @@ func (c *shimFunc6x1) Call6x1(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) in
|
1082 | 1085 |
|
1083 | 1086 | func ToFunc6x1(c Func) Func6x1 {
|
1084 | 1087 | if c.Type().NumIn() != 6 || c.Type().NumOut() != 1 {
|
1085 |
| - panic("incompatible func type") |
| 1088 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1086 | 1089 | }
|
1087 | 1090 | if sc, ok := c.(Func6x1); ok {
|
1088 | 1091 | return sc
|
@@ -1123,7 +1126,7 @@ func (c *shimFunc6x2) Call6x2(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (i
|
1123 | 1126 |
|
1124 | 1127 | func ToFunc6x2(c Func) Func6x2 {
|
1125 | 1128 | if c.Type().NumIn() != 6 || c.Type().NumOut() != 2 {
|
1126 |
| - panic("incompatible func type") |
| 1129 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1127 | 1130 | }
|
1128 | 1131 | if sc, ok := c.(Func6x2); ok {
|
1129 | 1132 | return sc
|
@@ -1164,7 +1167,7 @@ func (c *shimFunc6x3) Call6x3(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) (i
|
1164 | 1167 |
|
1165 | 1168 | func ToFunc6x3(c Func) Func6x3 {
|
1166 | 1169 | if c.Type().NumIn() != 6 || c.Type().NumOut() != 3 {
|
1167 |
| - panic("incompatible func type") |
| 1170 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1168 | 1171 | }
|
1169 | 1172 | if sc, ok := c.(Func6x3); ok {
|
1170 | 1173 | return sc
|
@@ -1205,7 +1208,7 @@ func (c *shimFunc7x0) Call7x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface
|
1205 | 1208 |
|
1206 | 1209 | func ToFunc7x0(c Func) Func7x0 {
|
1207 | 1210 | if c.Type().NumIn() != 7 || c.Type().NumOut() != 0 {
|
1208 |
| - panic("incompatible func type") |
| 1211 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1209 | 1212 | }
|
1210 | 1213 | if sc, ok := c.(Func7x0); ok {
|
1211 | 1214 | return sc
|
@@ -1246,7 +1249,7 @@ func (c *shimFunc7x1) Call7x1(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface
|
1246 | 1249 |
|
1247 | 1250 | func ToFunc7x1(c Func) Func7x1 {
|
1248 | 1251 | if c.Type().NumIn() != 7 || c.Type().NumOut() != 1 {
|
1249 |
| - panic("incompatible func type") |
| 1252 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 1 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1250 | 1253 | }
|
1251 | 1254 | if sc, ok := c.(Func7x1); ok {
|
1252 | 1255 | return sc
|
@@ -1287,7 +1290,7 @@ func (c *shimFunc7x2) Call7x2(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface
|
1287 | 1290 |
|
1288 | 1291 | func ToFunc7x2(c Func) Func7x2 {
|
1289 | 1292 | if c.Type().NumIn() != 7 || c.Type().NumOut() != 2 {
|
1290 |
| - panic("incompatible func type") |
| 1293 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 2 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1291 | 1294 | }
|
1292 | 1295 | if sc, ok := c.(Func7x2); ok {
|
1293 | 1296 | return sc
|
@@ -1328,7 +1331,7 @@ func (c *shimFunc7x3) Call7x3(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface
|
1328 | 1331 |
|
1329 | 1332 | func ToFunc7x3(c Func) Func7x3 {
|
1330 | 1333 | if c.Type().NumIn() != 7 || c.Type().NumOut() != 3 {
|
1331 |
| - panic("incompatible func type") |
| 1334 | + panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 3 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut())) |
1332 | 1335 | }
|
1333 | 1336 | if sc, ok := c.(Func7x3); ok {
|
1334 | 1337 | return sc
|
|
0 commit comments