Eric Milles created GROOVY-11137:
------------------------------------

             Summary: 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


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}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to