Skip to content

Commit 22a9a5a

Browse files
authored
Try to remove compiletime.Widen (#11569)
2 parents 3b524a4 + 859cdd2 commit 22a9a5a

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

library/src/scala/compiletime/package.scala

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,16 @@ package object compiletime {
100100
// implemented in dotty.tools.dotc.typer.Inliner
101101
error("Compiler bug: `constValue` was not evaluated by the compiler")
102102

103-
/**
104-
* Use this type to widen a self-type to a tuple. E.g.
105-
* ```scala
106-
* val x: (1, 3) = (1, 3)
107-
* val y: Widen[x.type] = x
108-
* ```
109-
* @syntax markdown
110-
*/
111-
type Widen[Tup <: Tuple] <: Tuple = Tup match {
112-
case EmptyTuple => EmptyTuple
113-
case h *: t => h *: t
114-
}
115-
116103
/** Given a tuple type `(X1, ..., Xn)`, returns a tuple value
117104
* `(constValue[X1], ..., constValue[Xn])`.
118105
*/
119-
inline def constValueTuple[T <: Tuple]: Widen[T]=
106+
inline def constValueTuple[T <: Tuple]: T =
120107
val res =
121108
inline erasedValue[T] match
122109
case _: EmptyTuple => EmptyTuple
123110
case _: (t *: ts) => constValue[t] *: constValueTuple[ts]
124111
end match
125-
res.asInstanceOf[Widen[T]]
112+
res.asInstanceOf[T]
126113
end constValueTuple
127114

128115
/** Summons first given matching one of the listed cases. E.g. in
@@ -159,16 +146,16 @@ package object compiletime {
159146
* @tparam T the tuple containing the types of the values to be summoned
160147
* @return the given values typed as elements of the tuple
161148
*/
162-
inline def summonAll[T <: Tuple]: Widen[T] =
149+
inline def summonAll[T <: Tuple]: T =
163150
val res =
164151
inline erasedValue[T] match
165152
case _: EmptyTuple => EmptyTuple
166153
case _: (t *: ts) => summonInline[t] *: summonAll[ts]
167154
end match
168-
res.asInstanceOf[Widen[T]]
155+
res.asInstanceOf[T]
169156
end summonAll
170157

171-
/** Succesor of a natural number where zero is the type 0 and successors are reduced as if the definition was
158+
/** Successor of a natural number where zero is the type 0 and successors are reduced as if the definition was
172159
*
173160
* ```scala
174161
* type S[N <: Int] <: Int = N match {

0 commit comments

Comments
 (0)