I originally asked in a discussion in Scala 3 GitHub, but I think this may be a better place for the question.
I’m trying to understand how the capability-based tracking of exceptions scale as you combine functions that use capabilities.
Following Capture Checking, I wrote this:
import caps.Capability
import language.experimental.captureChecking
import language.experimental.saferExceptions
class E1 extends Exception, Capability
class E2 extends Exception, Capability
class E3 extends Exception, Capability
class E4 extends Exception, Capability
def f1(): Unit throws E1 =
throw E1()
def f2(): Unit throws E2 =
throw E2()
def f3(): Unit throws E3 =
throw E3()
def f4(): Unit throws E4 =
throw E4()
def f5(): Unit throws E3 | E4 =
f3()
f4()
def f6(): Unit throws E1 | E2 | E3 | E4 =
f5()
f2()
f1()
Ideally I shouldn’t have to list all of the exception types in f6
. From the capture checking page linked above I thought I could do something like:
def f6: Unit^{f5, f2, f1} =
f5()
f2()
f1()
But this generates a few errors.. Is something like this allowed? What’s the right syntax?
Thanks.