Groovy
  1. Groovy
  2. GROOVY-5231

Problem with @TupleConstructor with static type checking

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-beta-3
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      When using the @TupleConstructor with the static type checking, it doesn't like when a constructor without all the fields is used.
      Consider the following example:

      import groovy.transform.*
      
      @TupleConstructor
      @TypeChecked
      class Person {
          String name, city
          static Person create() {
              new Person("Guillaume")
          }
      }
      
      Person.create()
      

      The type checker complains because it could not find a zero-arg constructor:

      [Static type checking] - Cannot find matching method Person#<init>(java.lang.String)
       at line: 8, column: 9
      

      But actually, @TupleConstructor allows to use less args than all the declared.
      Person can be instantiated with new Person("Guillaume", "Paris"), new Person("Guillaume"), or even new Person()

        Issue Links

          Activity

          Guillaume Delcroix created issue -
          Cédric Champeau made changes -
          Field Original Value New Value
          Link This issue is depended upon by GROOVY-5235 [ GROOVY-5235 ]
          Cédric Champeau made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Paul King made changes -
          Fix Version/s 2.0-beta-3 [ 18244 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12734154 ] Default workflow, editable Closed status [ 12745920 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12971638 ] Default workflow, editable Closed status [ 12979446 ]

            People

            • Assignee:
              Cédric Champeau
              Reporter:
              Guillaume Delcroix
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development