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

@NamedVariant with primitives can't find method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.14, 3.0.8
    • 2.5.16, 3.0.10, 4.0.0
    • None

    Description

      When using @NamedVariant on a method that uses primitives, it cannot invoke the underlying method.

       

      import groovy.transform.NamedVariant
      
      @NamedVariant
      def foo(String a = 'a', int b = 1, long c = 2L) {
       "$a-$b-$c"
      }
      
      assert foo(b: 2) == "a-2-2"
      

       

      You can also try it directly in the new Groovy Console.

      groovy.lang.MissingMethodException: No signature of method: Script1.foo() is applicable for argument types: (null, Integer, null) values: [null, 2, null]
      Possible solutions: foo(), foo(java.lang.String, int), foo(java.lang.String, int, long), foo(java.lang.String), foo(java.util.Map), run()
      	at Script1.foo(Script1.groovy)
      	at Script1$foo.callCurrent(Unknown Source)
      	at Script1.run(Script1.groovy:8) 

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              leonard84 Leonard Brünings
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: