Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.4
-
Fix Version/s: 1.8.5, 2.0-beta-2
-
Component/s: None
-
Labels:None
-
Number of attachments :
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.
Activity
Cedric Champeau
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Cedric Champeau [ melix ] |
Cedric Champeau
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.0-beta-2 [ 18072 ] | |
| Fix Version/s | 1.8.5 [ 18071 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |
As a workaround, resolved by improving javadoc. It now explains when setType should be called and what should be done when an accessed variable exists.