Skip to content

Commit 12eb487

Browse files
Drop asInstanceOf from the NamedTuple term ops where possible
1 parent f931a6d commit 12eb487

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

library/src-bootstrapped/scala/NamedTuple.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,14 @@ object NamedTupleDecomposition:
147147
inline def head: Head[NamedTuple[N, V]] = apply(0)
148148

149149
/** The last element value of this tuple */
150-
inline def last: Last[NamedTuple[N, V]] = apply(size - 1).asInstanceOf[Tuple.Last[V]]
150+
inline def last: Last[NamedTuple[N, V]] = apply(size - 1).asInstanceOf[Last[NamedTuple[N, V]]]
151151

152152
/** The tuple consisting of all elements of this tuple except the last one */
153153
inline def init: Init[NamedTuple[N, V]] =
154-
x.toTuple.take(size - 1).asInstanceOf[Init[NamedTuple[N, V]]]
154+
x.take(size - 1).asInstanceOf[Init[NamedTuple[N, V]]]
155155

156156
/** The tuple consisting of all elements of this tuple except the first one */
157-
inline def tail: Tail[NamedTuple[N, V]] =
158-
x.toTuple.drop(1).asInstanceOf[Tail[NamedTuple[N, V]]]
157+
inline def tail: Tail[NamedTuple[N, V]] = x.toTuple.drop(1)
159158

160159
/** The tuple consisting of the first `n` elements of this tuple, or all
161160
* elements if `n` exceeds `size`.
@@ -182,7 +181,7 @@ object NamedTupleDecomposition:
182181
* If `x = (n1 = v1, ..., ni = vi)` then `x.map(f) = `(n1 = f(v1), ..., ni = f(vi))`.
183182
*/
184183
inline def map[F[_]](f: [t] => t => F[t]): Map[NamedTuple[N, V], F] =
185-
x.toTuple.map(f).asInstanceOf[NamedTuple[N, Tuple.Map[V, F]]]
184+
x.toTuple.map(f)
186185

187186
/** The named tuple consisting of all elements of this tuple in reverse */
188187
inline def reverse: Reverse[NamedTuple[N, V]] = x.toTuple.reverse
@@ -198,7 +197,7 @@ object NamedTupleDecomposition:
198197
x.toTuple.zip(that.toTuple)
199198

200199
/** A list consisting of all element values */
201-
inline def toList: List[Tuple.Union[V]] = x.toTuple.toList.asInstanceOf[List[Tuple.Union[V]]]
200+
inline def toList: List[Tuple.Union[V]] = x.toTuple.toList
202201

203202
/** An array consisting of all element values */
204203
inline def toArray: Array[Object] = x.toTuple.toArray

0 commit comments

Comments
 (0)