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

@NamedVariant does not work on methods on a trait or default methods on an interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.0.6
    • None
    • None

    Description

      The following code fails to compile:

      import groovy.transform.NamedVariant
      
      trait Foo {
        @NamedVariant
        def foo(String username = "sdf", String email = "ghj") {}
      }
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mahoney Robert Elliot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: