Skip to content

Commit 8fb3c38

Browse files
committed
Make Label contravariant
Reduces number of type parameters in boundary from 2 to 1
1 parent 39e63f3 commit 8fb3c38

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/src/scala/util/boundary.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ object boundary:
2323

2424
/** Labels are targets indicating which boundary will be exited by a `break`.
2525
*/
26-
class Label[T]:
26+
class Label[-T]:
2727
def break(value: T): Nothing = throw Break(this, value)
2828

2929
/** Run `body` with freshly generated label as implicit argument. Catch any
3030
* breaks associated with that label and return their results instead of
3131
* `body`'s result.
3232
*/
33-
inline def apply[T <: R, R](inline body: Label[T] ?=> R): R =
33+
inline def apply[T](inline body: Label[T] ?=> T): T =
3434
val local = Label[T]()
3535
try body(using local)
3636
catch case ex: Break[T] @unchecked =>

0 commit comments

Comments
 (0)