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

[jira] [Created] (GROOVY-10816) @NamedVariant does not work on methods on a trait or default methods on an interface

Robert Elliot created GROOVY-10816:
--------------------------------------

             Summary: @NamedVariant does not work on methods on a trait or default methods on an interface
                 Key: GROOVY-10816
                 URL: https://issues.apache.org/jira/browse/GROOVY-10816
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.6
            Reporter: Robert Elliot


The following code fails to compile:

{code:groovy}
import groovy.transform.NamedVariant

trait Foo {
  @NamedVariant
  def foo(String username = "sdf", String email = "ghj") {}
}
{code}

with this error:

{{Groovyc: Error during @NamedVariant processing. Class Foo$Trait$Helper already has a named-arg method of type [org.codehaus.groovy.ast.Parameter@15247533[name: namedArgs, type: java.util.Map, hasDefaultValue: false]]}}

It works fine as a class.

It fails as an interface with a default method.

Perhaps this is intended, but if so I failed to find any documentation specifying that {{@NamedVariant}} only works with classes.



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