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 2022/11/06 17:39:00 UTC

[jira] [Resolved] (GROOVY-9857) Immutable generates invalid super constructor call

     [ https://issues.apache.org/jira/browse/GROOVY-9857?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-9857.
---------------------------------
    Fix Version/s: 4.0.7
       Resolution: Fixed

https://github.com/apache/groovy/commit/873e1952cf93373ad1eb348ef944fd628a3e9610

{{Immutable}} will not try and choose constructor.  You will however get an error now that there is no no-arg constructor to call and you must take some action.

> Immutable generates invalid super constructor call
> --------------------------------------------------
>
>                 Key: GROOVY-9857
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9857
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.7
>            Reporter: Christopher Smith
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.7
>
>
> The transforms invoked by {{@Immutable}} generate constructor code that unconditionally makes a call to {{super()}} even when the superclass has no default constructor.
> {code:groovy}
> @TupleConstructor(defaults = false)
> abstract class AbstractClass {
>     String a
> }
> @Immutable
> class ImmutableSubclass extends AbstractClass {
>     String i
> }
> {code}
> Compiling this pair produces {{invokespecial AbstractClass.<init>()}}, which does not exist. This should at a minimum produce a compile-time error.



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