Skip to content

Commit d640682

Browse files
committed
Mark CanThrow @experimental
1 parent 1001f80 commit d640682

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
package scala
22
import language.experimental.erasedDefinitions
3-
import annotation.implicitNotFound
3+
import annotation.{implicitNotFound, experimental}
44

55
/** An ability class that allows to throw exception `E`. When used with the
66
* experimental.saferExceptions feature, a `throw Ex()` expression will require
77
* a given of class `CanThrow[Ex]` to be available.
88
*/
9+
@experimental
910
@implicitNotFound("The ability to throw exception ${E} is missing.\nThe ability can be provided by one of the following:\n - A using clause `(using CanThrow[${E}])`\n - A `canThrow` clause in a result type such as `X canThrow ${E}`\n - an enclosing `try` that catches ${E}")
1011
erased class CanThrow[-E <: Exception]
1112

1213
/** A helper type to allow syntax like
1314
*
1415
* def f(): T canThrow Ex
1516
*/
17+
@experimental
1618
infix type canThrow[R, +E <: Exception] = CanThrow[E] ?=> R
1719

20+
@experimental
1821
object unsafeExceptions:
1922
given canThrowAny: CanThrow[Exception] = ???

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ object language:
5050

5151
/** Experimental support for using indentation for arguments
5252
*/
53+
@compileTimeOnly("`fewerBraces` can only be used at compile time in import statements")
5354
object fewerBraces
5455

5556
/** Experimental support for typechecked exception capabilities
5657
*
5758
* @see [[https://dotty.epfl.ch/docs/reference/experimental/canthrow]]
5859
*/
60+
@compileTimeOnly("`saferExceptions` can only be used at compile time in import statements")
5961
object saferExceptions
6062

6163
end experimental

0 commit comments

Comments
 (0)