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

@Canonical @TupleConstructor can't handle Object or Map properties

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.5
    • 2.1.3, 2.2.0-beta-1
    • None

    Description

      Given the following code, I would expect the assertions to pass. They currently don't. However, if the a and b properties are typed to String, for example, everything goes as expected.

      It might be challenging to get this to work properly for more complex types, but it would make the annotations really transparent. The way it currently behaves is very unsettling (a is set with a Map containing both a and b with their respective values, while b is not set to anything)

      import groovy.transform.Canonical
      
      def weird = new CanonicalIsWeird(a: 'first letter', b: 'second letter')
      println "a: ${weird.a}"
      println "b: ${weird.b}"
      
      assert weird.a == 'first letter'
      assert weird.b == 'second letter'
      
      @Canonical
      class CanonicalIsWeird {
          def a, b
      }
      

      https://gist.github.com/1565938

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              gjoseph Grégory Joseph
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: