Skip to content

Commit 70dd456

Browse files
committed
Try to remove compiletime.Widen
1 parent 4d0d591 commit 70dd456

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

library/src/scala/compiletime/package.scala

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,16 @@ package object compiletime {
9595
// implemented in dotty.tools.dotc.typer.Inliner
9696
error("Compiler bug: `constValue` was not evaluated by the compiler")
9797

98-
/**
99-
* Use this type to widen a self-type to a tuple. E.g.
100-
* ```
101-
* val x: (1, 3) = (1, 3)
102-
* val y: Widen[x.type] = x
103-
* ```
104-
*/
105-
type Widen[Tup <: Tuple] <: Tuple = Tup match {
106-
case EmptyTuple => EmptyTuple
107-
case h *: t => h *: t
108-
}
109-
11098
/** Given a tuple type `(X1, ..., Xn)`, returns a tuple value
11199
* `(constValue[X1], ..., constValue[Xn])`.
112100
*/
113-
inline def constValueTuple[T <: Tuple]: Widen[T]=
101+
inline def constValueTuple[T <: Tuple]: T =
114102
val res =
115103
inline erasedValue[T] match
116104
case _: EmptyTuple => EmptyTuple
117105
case _: (t *: ts) => constValue[t] *: constValueTuple[ts]
118106
end match
119-
res.asInstanceOf[Widen[T]]
107+
res.asInstanceOf[T]
120108
end constValueTuple
121109

122110
/** Summons first given matching one of the listed cases. E.g. in
@@ -151,16 +139,16 @@ package object compiletime {
151139
* @tparam T the tuple containing the types of the values to be summoned
152140
* @return the given values typed as elements of the tuple
153141
*/
154-
inline def summonAll[T <: Tuple]: Widen[T] =
142+
inline def summonAll[T <: Tuple]: T =
155143
val res =
156144
inline erasedValue[T] match
157145
case _: EmptyTuple => EmptyTuple
158146
case _: (t *: ts) => summonInline[t] *: summonAll[ts]
159147
end match
160-
res.asInstanceOf[Widen[T]]
148+
res.asInstanceOf[T]
161149
end summonAll
162150

163-
/** Succesor of a natural number where zero is the type 0 and successors are reduced as if the definition was
151+
/** Successor of a natural number where zero is the type 0 and successors are reduced as if the definition was
164152
*
165153
* type S[N <: Int] <: Int = N match {
166154
* case 0 => 1

0 commit comments

Comments
 (0)