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

@MapConstructor Breaks in Groovy4 when combined with @TupleConstructor, fine in Groovy3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.8
    • 4.0.9
    • None
    • None

    Description

      @MapConstructor Breaks in Groovy4 when combined with @TupleConstructor, fine in Groovy3

       

      Example in Groovy4

      import groovy.transform.*
      @MapConstructor(includeFields = true)
      @TupleConstructor(includeFields = true)
      @ToString(includeNames = true, includeFields = true)
      class Foo {    
        private final float w = 1    
        private final int x    
        private int y = 1    
        private final int z
      }
      println new Foo(x:2, z: 3)

      outputs the incorrect value

      Foo(x:2, y:0, z:3)

      In Groovy3 it outputs the correct 

      Foo(x:2, y:1, z:3)

      Also commenting out @TupleConstructor in Groovy4 causes the output to be the correct value. 

       

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              aibolit Aleks Tamarkin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: