[ https://issues.apache.org/jira/browse/GROOVY-7381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14546808#comment-14546808 ]
ASF GitHub Bot commented on GROOVY-7381: ---------------------------------------- GitHub user shils opened a pull request: https://github.com/apache/incubator-groovy/pull/17 GROOVY-7381: Setters with non-void return type fail at runtime when s… …tatically compiled You can merge this pull request into a Git repository by running: $ git pull https://github.com/shils/incubator-groovy GROOVY-7381-non-void-setters-sc Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-groovy/pull/17.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #17 ---- commit e097135d690ad85546209557c67e2b2f687cfabb Author: Shil S <shil.si...@gmail.com> Date: 2015-05-16T15:17:05Z GROOVY-7381: Setters with non-void return type fail at runtime when statically compiled ---- > Setters with non-void return type fail at runtime when statically compiled > -------------------------------------------------------------------------- > > Key: GROOVY-7381 > URL: https://issues.apache.org/jira/browse/GROOVY-7381 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.4.3 > Environment: OSX Yosemite, JDK 1.8.0_25 > Reporter: Shil Sinha > > Calling a statically compiled, non-void setter for a property will result in > a NoSuchMethodError being thrown at runtime. There is no error if the setter > corresponds to a field. > Example: > {code} > import groovy.transform.CompileStatic > @CompileStatic > class A { > int prop > private int field > A setProp(int prop) { > this.prop = prop > this > } > A setField(int field) { > this.field = field > this > } > static void main(String[] args) { > A a = new A() > a.setField(1) // ok > a.setProp(1) //throws NoSuchMethodError at runtime > } > } > A a = new A() > a.setField(1) //ok > a.setProp(1) //throws NoSuchMethodError > {code} > The problem appears to be in the `makeSetProperty` method of > `StaticTypesBinaryExpressionMultiTypeDispatcher`, where only void setter > methods of a ClassNode are looked up. > The most recent version of Groovy where this isn't an issue is 2.3.3. -- This message was sent by Atlassian JIRA (v6.3.4#6332)