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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.5
    • Fix Version/s: 2.1.3, 2.2.0-beta-1
    • Component/s: None
    • Labels:

      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

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: