Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.1
-
None
Description
InnerClassCompletionVisitor adds methodMissing and propertyMissing impls to static inner classes.
public java.lang.Object methodMissing(java.lang.String name, java.lang.Object args) { return Container."$name"(* args ) } public void propertyMissing(java.lang.String name, java.lang.Object val) { Container."$name" = val } public java.lang.Object propertyMissing(java.lang.String name) { return Container."$name" }
The issue is, whenever one of these is defined by the user InnerClassCompletionVisitor takes the already existing MethodNode and replaces its method block.
This leads to errors if the custom impl has chosen other parameter names as the InnerClassCompletionVisitor code expects:
class A { static class B { def propertyMissing(String name, Object myValue) { return value } } } def b = new A.B() b.a = 'test' // groovy.lang.MissingFieldException: No such field: val for class: A
The MissingFieldException is thrown because there is no parameter named val in the user-defined method interface of propertyMissing.