-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow experimental erased in experimental scopes
Closes #13392
- Loading branch information
1 parent
9696219
commit 791aeb3
Showing
8 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
tests/neg-custom-args/no-experimental/experimental-erased.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import language.experimental.erasedDefinitions // error | ||
import language.experimental.erasedDefinitions | ||
import annotation.experimental | ||
|
||
@experimental | ||
erased class CanThrow[-E <: Exception] | ||
|
||
erased class CanThrow2[-E <: Exception] // error | ||
|
||
def other = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/neg-custom-args/no-experimental/experimentalErased.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import language.experimental.erasedDefinitions | ||
import annotation.experimental | ||
|
||
@experimental | ||
erased class Foo | ||
|
||
erased class Bar // error | ||
|
||
@experimental | ||
erased def foo = 2 | ||
|
||
erased def bar = 2 // error | ||
|
||
@experimental | ||
erased val foo2 = 2 | ||
|
||
erased val bar2 = 2 // error | ||
|
||
@experimental | ||
def foo3(erased a: Int) = 2 | ||
|
||
def bar3(erased a: Int) = 2 // error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import language.experimental.erasedDefinitions | ||
import annotation.experimental | ||
|
||
@experimental | ||
erased class Foo | ||
|
||
erased class Bar | ||
|
||
@experimental | ||
erased def foo = 2 | ||
|
||
erased def bar = 2 | ||
|
||
@experimental | ||
erased val foo2 = 2 | ||
|
||
erased val bar2 = 2 | ||
|
||
@experimental | ||
def foo3(erased a: Int) = 2 | ||
|
||
def bar3(erased a: Int) = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package scala | ||
import language.experimental.erasedDefinitions | ||
import annotation.{implicitNotFound, experimental} | ||
|
||
@experimental | ||
@implicitNotFound("The capability to throw exception ${E} is missing.\nThe capability can be provided by one of the following:\n - A using clause `(using CanThrow[${E}])`\n - A `throws` clause in a result type such as `X throws ${E}`\n - an enclosing `try` that catches ${E}") | ||
erased class CanThrow[-E <: Exception] | ||
|
||
@experimental | ||
object unsafeExceptions: | ||
given canThrowAny: CanThrow[Exception] = ??? |