-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently, there is no support for runtime type tests. There are two aspects:
- Type Tests. The test itself gets unwrapped into a tag equality test.
- Coercions. Subsequent uses of the variable are automatically coerced.
As a rough example, consider this Whiley function:
function get(int|null x) -> (int r):
if x is int:
return x
else:
return 0
This would be translated into this Java:
static BigInteger get(Union x) {
if(x.isInt()) {
return x.asBigInteger();
} else {
return BigInteger.ZERO;
}
}
The need for the coercion should be evident from the target type of x at the variable access. Basically, we have an implicit coercion from int|null to int.
Metadata
Metadata
Assignees
Labels
No labels