You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/09/25 23:35:00 UTC

[jira] [Commented] (GROOVY-11451) IncompatibleClassChange with map-style constructor and overloaded setters

    [ https://issues.apache.org/jira/browse/GROOVY-11451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17884809#comment-17884809 ] 

Eric Milles commented on GROOVY-11451:
--------------------------------------

Can you provide any more detail or a small script?

> IncompatibleClassChange with map-style constructor and overloaded setters
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-11451
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11451
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 4.0.22
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Critical
>
> I have a POJO that I use from Groovy code. After adding a setter overload, I now get {{IncompatibleClassChange}} at runtime because the static compiler generates {{ScriptBytecodeAdapter.setGroovyObjectProperty}} instead of a plain setter call.
> {code}
> public class Entity {
>   public void setId(String id) {}
>   public void setId(UUID id) {}
> }
> class EntityTest extends Specification {
>   @CompileStatic
>   Entity createEntity(String id) {
>     new Entity(id: id) // uses ScriptBytecodeAdapter.setGroovyObjectProperty
>   }
> }
> {code}
> The error is not encountered when calling {{setId(id)}} or using {{entity.id = id}}, without static compilation, or when the setter is not overloaded.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)