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 2020/12/14 21:20:00 UTC

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

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

Eric Milles commented on GROOVY-9857:
-------------------------------------

Call to super class default constructor is added by {{AsmClassGenerator#visitStdMethod}}.  I don't think {{groovy.transform.Immutable}} is required for there to be an issue.

> 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
>            Priority: Minor
>
> 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.3.4#803005)