Skip to content

Commit 5da1855

Browse files
authored
Move NamedTuple.head to NamedTupleDecomposition (#21308)
This is in particular necessary for #21291, to avoid problems encountered after inlining from scopes defining opaque types (such as in the example below), as was already done for the other NamedTuple operations in #20504.
2 parents 927eb5b + 32e4056 commit 5da1855

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/src/scala/NamedTuple.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object NamedTuple:
3030

3131
export NamedTupleDecomposition.{
3232
Names, DropNames,
33-
apply, size, init, last, tail, take, drop, splitAt, ++, map, reverse, zip, toList, toArray, toIArray
33+
apply, size, init, head, last, tail, take, drop, splitAt, ++, map, reverse, zip, toList, toArray, toIArray
3434
}
3535

3636
extension [N <: Tuple, V <: Tuple](x: NamedTuple[N, V])
@@ -43,9 +43,6 @@ object NamedTuple:
4343
// and should be reverted, just like NonEmptyList is also appealing at first, but a bad idea
4444
// in the end.
4545

46-
/** The first element value of this tuple */
47-
inline def head: Tuple.Elem[V, 0] = x.apply(0)
48-
4946
// inline def :* [L] (x: L): NamedTuple[Append[N, ???], Append[V, L] = ???
5047
// inline def *: [H] (x: H): NamedTuple[??? *: N], H *: V] = ???
5148

@@ -149,6 +146,9 @@ object NamedTupleDecomposition:
149146
/** The number of elements in this tuple */
150147
inline def size: Tuple.Size[V] = x.toTuple.size
151148

149+
/** The first element value of this tuple */
150+
inline def head: Tuple.Elem[V, 0] = apply(0)
151+
152152
/** The last element value of this tuple */
153153
inline def last: Tuple.Last[V] = apply(size - 1).asInstanceOf[Tuple.Last[V]]
154154

0 commit comments

Comments
 (0)