Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.2
-
None
-
JDK 1.7.0_04
Description
When accessing field 'x' that have the same name as property 'getX'
compiler try to access the property instead of field.
If you remove the property accessor 'getX' then error disappears
I don't know if it just compile time or also run-time.
The complete test case below demonstrates it:
class CSFieldConfuseProperty { private AtomicBoolean x; @CompileStatic public boolean getX() { return x.get(); } /** * This one gives error: * Groovyc: [Static type checking] - Cannot find matching method boolean#set(boolean). * Please check if the declared type is right and if the method exists. */ @CompileStatic public void setX1(boolean flag) { this.x.set(flag); } /** * This cone is compiled OK */ public void setX2(boolean flag) { this.x.set(flag); } }