You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importlanguage.experimental.saferExceptionscaseclassEx[A](a: A) extendsException(s"Ex: $a")
deffoo[A](a: A):Unit throws Ex[A] =thrownewEx(a)
deftest():Unit=try
foo(1)
catchcaseEx(i: Int) => println("Caught an Int")
Output
[error] The capability can be provided by one of the following:
[error] -A using clause `(using CanThrow[Ex[Int]])`
[error] -A `throws` clause in a result typesuch as `X throws Ex[Int]`
[error] - an enclosing `try` that catches Ex[Int]
[error]
[error] The following importmightfixtheproblem:
[error]
[error] importunsafeExceptions.canThrowAny
[error]
[error] foo(1)
[error]
Expectation
This should compile successfully.
If one tries to compile this code with -Xprint:typer one can see that the entire try/catch block gets desugared to
where A$1 does not get substituted with Int as expected.
Interestingly, the error does not occur if we define case class Ex[+A](a: A) with a covariant type parameter
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.1.2-RC1-bin-20211101-49b6c08-NIGHTLY
Minimized code
Output
Expectation
This should compile successfully.
If one tries to compile this code with
-Xprint:typer
one can see that the entire try/catch block gets desugared towhere
A$1
does not get substituted withInt
as expected.Interestingly, the error does not occur if we define
case class Ex[+A](a: A)
with a covariant type parameterThe text was updated successfully, but these errors were encountered: