<< §2.3.2.(c) Declared lifting of arrays | ↑ Table of Contents ↑ | §2.3.2.(e) Generic declared lifting >> |
§2.3.2.(d) Declared lifting for catch blocks
Also the argument of a catch block may apply declared lifting like in:
catch (BaseException as RoleClass param) { stmts }
This syntax is only valid in a non-static scope of a team (directly or nested).
In the given example, RoleClass
must be played by BaseException
.
Note, that RoleClass
itself need not be a throwable.
As the effect of this declaration the catch block will catch any exception of type BaseException
and provides it wrapped with a RoleClass
instance to the subsequent block.
Also note, that re-throwing the given instance param
has the semantics of implicitly lowering
the role to its base exception before throwing, because the role conforms to the required type
Throwable
only via lowering.
<< §2.3.2.(c) Declared lifting of arrays | ↑ Table of Contents ↑ | §2.3.2.(e) Generic declared lifting >> |