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

Disallow setting of type on VariableExpression if isClosureSharedVariable() returns true from AST transforms

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.4
    • 1.8.5, 2.0-beta-2
    • None
    • None

    Description

      If you set the type of a shared closure variable to something else then this leads to a VerifierError such as:

      Caused by: java.lang.VerifyError: (class: org/example/BookController, method: test signature: ()Ljava/lang/Object;) Incompatible argument to function
      	at java.lang.Class.getDeclaredFields0(Native Method)
      	at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
      	at java.lang.Class.getDeclaredFields(Class.java:1743)
      
      

      This is because the Groovy is expecting a Reference but gets the new type that was set in an AST transform. Either a better error needs to be produced or you should not be allowed to set the type of a Reference to avoid painful debugging experience for users.

      Attachments

        Activity

          People

            melix Cédric Champeau
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: