We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feels like java :)
scala> import annotation.effects._ import annotation.effects._ scala> class E1 extends Exception defined class E1 scala> trait Fun[A, B, E <: Exception] { def apply(a: A): B @throws[E] } defined trait Fun scala> def foo[E <: Exception](fun: Fun[Int, Int, E]): Int @throws[E] = fun(1) foo: [E <: Exception](fun: Fun[Int,Int,E])Int @scala.annotation.effects.throws[E] scala> foo(new Fun[Int, Int, Nothing] { def apply(x: Int) = x }) res1: Int @scala.annotation.effects.throws[Nothing] = 1 scala> foo(new Fun[Int, Int, E1] { def apply(x: Int) = x }) res2: Int @scala.annotation.effects.throws[Nothing] = 1 scala> foo(new Fun[Int, Int, Nothing] { def apply(x: Int) = throw new E1 }) <console>:14: error: overriding method apply in trait Fun of type (a: Int)Int @scala.annotation.effects.throws[Nothing]; method apply has incompatible type foo(new Fun[Int, Int, Nothing] { def apply(x: Int) = throw new E1 }) ^
this one in fact does not seem to work:
scala> def bar = foo(new Fun[Int, Int, E1] { def apply(x: Int): Int @throws[E1] = x }) bar: Int @scala.annotation.effects.throws[Nothing]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
feels like java :)
this one in fact does not seem to work:
The text was updated successfully, but these errors were encountered: