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

Wrong argument type when using static method from nested class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.16, 3.0.10, 4.0.1
    • 2.5.17, 3.0.11, 4.0.2
    • None
    • None

    Description

      class Example {
          static byte[] hash(byte[] bytes) {
              bytes
          }
          static class Nested {        
              def getCacheKey(byte[] payload) {
                  hash(payload)
                  // hash(payload as byte[]) fails as well 
                  // Example.hash(payload) works
              }
          }
      }
      
      new Example.Nested().getCacheKey("bar".bytes)
      

      fails with

      groovy.lang.MissingMethodException: No signature of method: static Example.hash() is applicable for argument types: (ArrayList) values: [[98, 97, 114]]
      Possible solutions: hash([B), each(groovy.lang.Closure), wait(), any(), wait(long), is(java.lang.Object)
      	at Example$Nested.methodMissing(Script1.groovy)
      	at Example$Nested.getCacheKey(Script1.groovy:7)
      	at Example$Nested$getCacheKey.call(Unknown Source)
      	at Script1.run(Script1.groovy:14)
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: