@@ -8,6 +8,113 @@ import scala.annotation.implicitNotFound
8
8
* @tparam G a tupled function type (function of arity 1 receiving a tuple as argument)
9
9
*/
10
10
@ implicitNotFound(" ${F} cannot be tupled as ${G}" )
11
- trait TupledFunction [F , G ] {
11
+ sealed trait TupledFunction [F , G ] {
12
12
def apply (f : F ): G
13
13
}
14
+
15
+ package internal {
16
+
17
+ object TupledFunction {
18
+
19
+ def tupledFunction0 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
20
+ def apply (f : F ): G =
21
+ ((args : Unit ) => f.asInstanceOf [() => Any ].apply()).asInstanceOf [G ]
22
+ }
23
+
24
+ def tupledFunction1 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
25
+ def apply (f : F ): G =
26
+ ((args : Tuple1 [Any ]) => f.asInstanceOf [Any => Any ].apply(args._1)).asInstanceOf [G ]
27
+ }
28
+
29
+ def tupledFunction2 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
30
+ def apply (f : F ): G = f.asInstanceOf [Function2 [_, _, _]].tupled.asInstanceOf [G ]
31
+ }
32
+
33
+ def tupledFunction3 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
34
+ def apply (f : F ): G = f.asInstanceOf [Function3 [_, _, _, _]].tupled.asInstanceOf [G ]
35
+ }
36
+
37
+ def tupledFunction4 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
38
+ def apply (f : F ): G = f.asInstanceOf [Function4 [_, _, _, _, _]].tupled.asInstanceOf [G ]
39
+ }
40
+
41
+ def tupledFunction5 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
42
+ def apply (f : F ): G = f.asInstanceOf [Function5 [_, _, _, _, _, _]].tupled.asInstanceOf [G ]
43
+ }
44
+
45
+ def tupledFunction6 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
46
+ def apply (f : F ): G = f.asInstanceOf [Function6 [_, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
47
+ }
48
+
49
+ def tupledFunction7 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
50
+ def apply (f : F ): G = f.asInstanceOf [Function7 [_, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
51
+ }
52
+
53
+ def tupledFunction8 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
54
+ def apply (f : F ): G = f.asInstanceOf [Function8 [_, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
55
+ }
56
+
57
+ def tupledFunction9 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
58
+ def apply (f : F ): G = f.asInstanceOf [Function9 [_, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
59
+ }
60
+
61
+ def tupledFunction10 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
62
+ def apply (f : F ): G = f.asInstanceOf [Function10 [_, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
63
+ }
64
+
65
+ def tupledFunction11 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
66
+ def apply (f : F ): G = f.asInstanceOf [Function11 [_, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
67
+ }
68
+
69
+ def tupledFunction12 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
70
+ def apply (f : F ): G = f.asInstanceOf [Function12 [_, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
71
+ }
72
+
73
+ def tupledFunction13 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
74
+ def apply (f : F ): G = f.asInstanceOf [Function13 [_, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
75
+ }
76
+
77
+ def tupledFunction14 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
78
+ def apply (f : F ): G = f.asInstanceOf [Function14 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
79
+ }
80
+
81
+ def tupledFunction15 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
82
+ def apply (f : F ): G = f.asInstanceOf [Function15 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
83
+ }
84
+
85
+ def tupledFunction16 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
86
+ def apply (f : F ): G = f.asInstanceOf [Function16 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
87
+ }
88
+
89
+ def tupledFunction17 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
90
+ def apply (f : F ): G = f.asInstanceOf [Function17 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
91
+ }
92
+
93
+ def tupledFunction18 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
94
+ def apply (f : F ): G = f.asInstanceOf [Function18 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
95
+ }
96
+
97
+ def tupledFunction19 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
98
+ def apply (f : F ): G = f.asInstanceOf [Function19 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
99
+ }
100
+
101
+ def tupledFunction20 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
102
+ def apply (f : F ): G = f.asInstanceOf [Function20 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
103
+ }
104
+
105
+ def tupledFunction21 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
106
+ def apply (f : F ): G = f.asInstanceOf [Function21 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
107
+ }
108
+
109
+ def tupledFunction22 [F , G ]: TupledFunction [F , G ] = new TupledFunction {
110
+ def apply (f : F ): G = f.asInstanceOf [Function22 [_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _]].tupled.asInstanceOf [G ]
111
+ }
112
+
113
+ def tupledFunctionXXL [F , G ]: TupledFunction [F , G ] = new TupledFunction {
114
+ def apply (f : F ): G =
115
+ ((args : TupleXXL ) => f.asInstanceOf [FunctionXXL ].apply(args.elems)).asInstanceOf [G ]
116
+ }
117
+
118
+ }
119
+
120
+ }
0 commit comments