[
https://issues.apache.org/jira/browse/GROOVY-11137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-11137:
---------------------------------
Description:
Union types are partially supported:
{code:groovy}
try {
foo()
} catch (Exception | Error e) { // parses
e.printStackTrace() // flow type of e is probably Throwable currently
}
{code}
But don't have direct representation or support in the AST.
Intersection types (declared with {{&}}) are not supported:
{code:groovy}
// parses as method call: (a & b).call({ ... })
var fun = (Function<String,String> & Serializable) { x -> x }
void test(Number number) {
if (number instanceof Comparable) {
number // flow type is (Number & Comparable)
}
}
{code}
was:
Union types are partially supported:
{code:groovy}
try {
foo()
} catch (Exception | Error e) {
}
{code}
But don't have direct representation or support in the AST.
Intersection types (declared with {{&}}) are not supported:
{code:groovy}
// parses as method call: (a & b).call({ ... })
var fun = (Function<String,String> & Serializable) { x -> x }
void test(Number number) {
if (number instanceof Comparable) {
number // flow type is (Number & Comparable)
}
}
{code}
> Improve support for union and intersection types
> ------------------------------------------------
>
> Key: GROOVY-11137
> URL: https://issues.apache.org/jira/browse/GROOVY-11137
> Project: Groovy
> Issue Type: Improvement
> Reporter: Eric Milles
> Priority: Major
>
> Union types are partially supported:
> {code:groovy}
> try {
> foo()
> } catch (Exception | Error e) { // parses
> e.printStackTrace() // flow type of e is probably Throwable currently
> }
> {code}
> But don't have direct representation or support in the AST.
> Intersection types (declared with {{&}}) are not supported:
> {code:groovy}
> // parses as method call: (a & b).call({ ... })
> var fun = (Function<String,String> & Serializable) { x -> x }
> void test(Number number) {
> if (number instanceof Comparable) {
> number // flow type is (Number & Comparable)
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)