@@ -101,50 +101,50 @@ object Tuple {
101
101
*/
102
102
def *: (tail : Tail ): H *: Tail = runtime.Tuples .cons(x, tail).asInstanceOf [H *: Tail ]
103
103
104
- extension [ This <: Tuple ] (tuple : This )
104
+ extension (tuple : Tuple )
105
105
/** Get the head of this tuple */
106
- def head : Head [This ] & Head [tuple.type ] =
106
+ def head [ This >: tuple. type <: Tuple ] : Head [This ] & Head [tuple.type ] =
107
107
runtime.Tuples .apply(tuple, 0 ).asInstanceOf [Head [This ] & Head [tuple.type ]]
108
108
109
109
/** Get the tail of this tuple.
110
110
* This operation is O(tuple.size)
111
111
*/
112
- def tail : Tail [This ] & Tail [tuple.type ] =
112
+ def tail [ This >: tuple. type <: Tuple ] : Tail [This ] & Tail [tuple.type ] =
113
113
runtime.Tuples .tail(tuple).asInstanceOf [Tail [This ] & Tail [tuple.type ]]
114
114
115
115
/** Return the size (or arity) of the tuple */
116
- def size : Size [This ] & Size [tuple.type ] =
116
+ def size [ This >: tuple. type <: Tuple ] : Size [This ] & Size [tuple.type ] =
117
117
runtime.Tuples .size(tuple).asInstanceOf [Size [This ] & Size [tuple.type ]]
118
118
119
119
/** Get the i-th element of this tuple.
120
120
* Equivalent to productElement but with a precise return type.
121
121
*/
122
- def apply (n : Int ): Elem [This , n.type ] & Elem [tuple.type , n.type ] =
122
+ def apply [ This >: tuple. type <: Tuple ] (n : Int ): Elem [This , n.type ] & Elem [tuple.type , n.type ] =
123
123
runtime.Tuples .apply(tuple, n).asInstanceOf [Elem [This , n.type ] & Elem [tuple.type , n.type ]]
124
124
125
125
/** Get the initial part of the tuple without its last element */
126
- def init : Init [This ] & Init [tuple.type ] =
126
+ def init [ This >: tuple. type <: Tuple ] : Init [This ] & Init [tuple.type ] =
127
127
runtime.Tuples .init(tuple).asInstanceOf [Init [This ] & Init [tuple.type ]]
128
128
129
129
/** Get the last of this tuple */
130
- def last : Last [This ] & Last [tuple.type ] =
130
+ def last [ This >: tuple. type <: Tuple ] : Last [This ] & Last [tuple.type ] =
131
131
runtime.Tuples .last(tuple).asInstanceOf [Last [This ] & Last [tuple.type ]]
132
132
133
133
/** Return a copy of `tuple` with an element appended */
134
- def :* [X ] (x : X ): Append [This , X ] & Append [tuple.type , X ] =
134
+ def :* [This >: tuple. type <: Tuple , X ] (x : X ): Append [This , X ] & Append [tuple.type , X ] =
135
135
runtime.Tuples .append(x, tuple).asInstanceOf [Append [This , X ] & Append [tuple.type , X ]]
136
136
137
137
/** Return a new tuple by concatenating `this` tuple with `that` tuple.
138
138
* This operation is O(this.size + that.size)
139
139
*/
140
- def ++ (that : Tuple ): Concat [This , that.type ] & Concat [tuple.type , that.type ] =
140
+ def ++ [ This >: tuple. type <: Tuple ] (that : Tuple ): Concat [This , that.type ] & Concat [tuple.type , that.type ] =
141
141
runtime.Tuples .concat(tuple, that).asInstanceOf [Concat [This , that.type ] & Concat [tuple.type , that.type ]]
142
142
143
143
/** Given a tuple `(a1, ..., am)`, returns the reversed tuple `(am, ..., a1)`
144
144
* consisting all its elements.
145
145
*/
146
146
@ experimental
147
- def reverse : Reverse [This ] & Reverse [tuple.type ] =
147
+ def reverse [ This >: tuple. type <: Tuple ] : Reverse [This ] & Reverse [tuple.type ] =
148
148
runtime.Tuples .reverse(tuple).asInstanceOf [Reverse [This ] & Reverse [tuple.type ]]
149
149
150
150
/** Given two tuples, `(a1, ..., an)` and `(a1, ..., an)`, returns a tuple
@@ -155,38 +155,38 @@ object Tuple {
155
155
* `(A1, B1) *: ... *: (Ai, Bi) *: Tuple`
156
156
*/
157
157
// TODO change signature? def zip[That <: Tuple](that: That): Zip[This, tuple.type] & Zip[tuple.type, tuple.type] =
158
- def zip [That <: Tuple ](that : That ): Zip [This , That ] & Zip [tuple.type , That ] =
158
+ def zip [This >: tuple. type <: Tuple , That <: Tuple ](that : That ): Zip [This , That ] & Zip [tuple.type , That ] =
159
159
runtime.Tuples .zip(tuple, that).asInstanceOf [Zip [This , That ] & Zip [tuple.type , That ]]
160
160
161
161
/** Called on a tuple `(a1, ..., an)`, returns a new tuple `(f(a1), ..., f(an))`.
162
162
* The result is typed as `(F[A1], ..., F[An])` if the tuple type is fully known.
163
163
* If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
164
164
* to be the cons type.
165
165
*/
166
- def map [F [_]](f : [t] => t => F [t]): Map [This , F ] & Map [tuple.type , F ] =
166
+ def map [This >: tuple. type <: Tuple , F [_]](f : [t] => t => F [t]): Map [This , F ] & Map [tuple.type , F ] =
167
167
runtime.Tuples .map(tuple, f).asInstanceOf [Map [This , F ] & Map [tuple.type , F ]]
168
168
169
169
/** Given a tuple `(a1, ..., am)`, returns the tuple `(a1, ..., an)` consisting
170
170
* of its first n elements.
171
171
*/
172
- def take (n : Int ): Take [This , n.type ] & Take [tuple.type , n.type ] =
172
+ def take [ This >: tuple. type <: Tuple ] (n : Int ): Take [This , n.type ] & Take [tuple.type , n.type ] =
173
173
runtime.Tuples .take(tuple, n).asInstanceOf [Take [This , n.type ] & Take [tuple.type , n.type ]]
174
174
175
175
/** Given a tuple `(a1, ..., am)`, returns the tuple `(an+1, ..., am)` consisting
176
176
* all its elements except the first n ones.
177
177
*/
178
- def drop (n : Int ): Drop [This , n.type ] & Take [tuple.type , n.type ] =
178
+ def drop [ This >: tuple. type <: Tuple ] (n : Int ): Drop [This , n.type ] & Take [tuple.type , n.type ] =
179
179
runtime.Tuples .drop(tuple, n).asInstanceOf [Drop [This , n.type ] & Take [tuple.type , n.type ]]
180
180
181
181
/** Given a tuple `(a1, ..., am)`, returns a pair of the tuple `(a1, ..., an)`
182
182
* consisting of the first n elements, and the tuple `(an+1, ..., am)` consisting
183
183
* of the remaining elements.
184
184
*/
185
- def splitAt (n : Int ): Split [This , n.type ] & Split [tuple.type , n.type ] =
185
+ def splitAt [ This >: tuple. type <: Tuple ] (n : Int ): Split [This , n.type ] & Split [tuple.type , n.type ] =
186
186
runtime.Tuples .splitAt(tuple, n).asInstanceOf [Split [This , n.type ] & Split [tuple.type , n.type ]]
187
187
188
188
/** Create a copy of this tuple as a List */
189
- def toList : List [Union [This ]] & List [Union [tuple.type ]] =
189
+ def toList [ This >: tuple. type <: Tuple ] : List [Union [This ]] & List [Union [tuple.type ]] =
190
190
tuple.productIterator.toList.asInstanceOf [List [Union [This ]] & List [Union [tuple.type ]]]
191
191
end extension
192
192
0 commit comments