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)
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.