Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9857

Immutable generates invalid super constructor call

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.7
    • 4.0.7
    • None
    • None

    Description

      The transforms invoked by @Immutable generate constructor code that unconditionally makes a call to super() even when the superclass has no default constructor.

      @TupleConstructor(defaults = false)
      abstract class AbstractClass {
          String a
      }
      
      @Immutable
      class ImmutableSubclass extends AbstractClass {
          String i
      }
      

      Compiling this pair produces invokespecial AbstractClass.<init>(), which does not exist. This should at a minimum produce a compile-time error.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              chrylis Christopher Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: