Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11137

Improve support for union and intersection types

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Union types are partially supported:

      try {
       foo()
      } catch (Exception | Error e) { // parses
        e.printStackTrace() // flow type of e is probably Throwable but should be (Exception | Error)
      }
      

      But don't have direct representation or support in the AST.

      Intersection types (declared with &) are not supported:

      // 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 ? but should be (Number & Comparable)
        }
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              emilles Eric Milles
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: