You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/11/22 23:48:00 UTC

[jira] [Created] (GROOVY-10854) record cannot be adjusted by @RecordType annotation

Eric Milles created GROOVY-10854:
------------------------------------

             Summary: record cannot be adjusted by @RecordType annotation
                 Key: GROOVY-10854
                 URL: https://issues.apache.org/jira/browse/GROOVY-10854
             Project: Groovy
          Issue Type: Bug
            Reporter: Eric Milles
            Assignee: Eric Milles


Consider the following:
{code:groovy}
@RecordType(defaults=false, namedVariant=false)
record Person(String name, Date dob) {
  //Person(String,Date)
  //Person(String)  no!
  //Person(Map)     no!
  //Person()        no!

  public Person { // implies @TupleConstructor(pre={...})
    assert name.length() > 1
  }

  Person(Person that) {
    this(that.name(), that.dob())
  }

  //getAt(int i)
  //toList()
  //toMap()
}
{code}

The goal is to disable all the extra constructors and {{@RecordType}} fails to do so.  This is because there is an implicit {{@RecordType()}} annotation added by the parser that gets in the way of correct merged attributes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)