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

NamedVariant: default value overrides supplied value if it's falsy (positional parameter)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.10, 4.0.0
    • None
    • None

    Description

      Consider the following:

      import groovy.transform.*
      
      @ToString(includeNames=true)
      class Color {
        int r, g, b
      }
      
      @NamedVariant
      String m(@NamedDelegate Color color, Number alpha=4.5) {
        return [color, alpha].join(' ')
      }
      print m(r:1, g:2, b:3, 0.0) // "Color(r:1, g:2, b:3) 4.5"!
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              emilles Eric Milles
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: