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

var keyword support: finalize behavior of keyword under static compilation



    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • 5.x
    • None
    • None


      As part of GROOVY-8498 there is now support for the var keyword to provide compatibility with:
      http://openjdk.java.net/jeps/286 (Java 10)
      http://openjdk.java.net/jeps/323 (targeted for Java 11)

      For dynamic Groovy, var is an alias for def. Under @CompileStatic, there are three fairly obvious potential behaviors that could make sense for Groovy:

      • a direct alias for def in which case normal Groovy flow typing would apply (this is currently what is implemented but is more flexible than what Java developers might expect)
      • similar to the alias for def in that it allows the inferred type to change as further instructions are executed but it would only be allowed to change to sub-types of the initially inferred type (needs further investigation but if possible would combine some of the nice aspects of Groovy def and Java var behavior)
      • a direct equivalent of Java (this would be the most work and would differ greatly from Groovy behavior and in general would be hard to marry up with Groovy semantics)
        We need to finalize the behavior we want before releasing non-alpha versions of Groovy 3.


        Issue Links



              Unassigned Unassigned
              daniel_sun Daniel Sun
              1 Vote for this issue
              2 Start watching this issue