title: Groovy can't find a method matching my arguments
body: <p>I'm befuddled with a Groovy method resolution problem.</p>
  
  <p>I'm working in the Groovy code for a Gradle custom plugin.</p>
  
  <p>I have the following code in a method of my Task class:</p>
  
  <pre><code>    if (inspectDependencies) {
          project.configurations[yangFilesConfiguration].files.each { File file -&gt;
              println file
              println "filetype:${file.getClass().getName()} excludeFilesType:${excludeFiles.getClass().getName()}"
              this.getYangFilesFromZip(file, excludeFiles).each { File yangFile
                  println yangFile
              }
          }
      }
  </code></pre>
  
  <p>I also have a method definition later in the same Task class:</p>
  
  <pre><code>    private Collection&lt;File&gt; getYangFilesFromZip(File file, Collection&lt;String&gt; excludeFiles) {
      ....
  </code></pre>
  
  <p>When I run this code, I see the following:</p>
  
  <pre><code>filetype:java.io.File excludeFilesType:java.util.ArrayList
  ...
  Could not find method getYangFilesFromZip() for arguments [C:\Users\dk068x\workspace2\YangUsingProject\libs\config-api-0.3.0-SNAPSHOT.jar, [target.yang]] on task ':yangGenerate'.
  </code></pre>
  
  <p>As you can see, the actual types of the parameters are compatible with the formal parameters of the method.  What could be going wrong here?</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I added the following line between the first println and the call to "getYangFilesFromZip":</p>
  
  <pre><code>print "this[$this] owner[$owner] delegate[$delegate]"
  </code></pre>
  
  <p>When I run it, it prints:</p>
  
  <pre><code>this[task ':yangGenerate'] owner[task ':yangGenerate'] delegate[task ':yangGenerate']
  </code></pre>
  
  <p>I also tried the variations in the call itself, with "getYangFilesFromZip", "this.getYangFilesFromZip", and "owner.getYangFilesFromZip".  I even tried declaring a "YangGenerate" variable before the closure and assigning it from "this" and referencing that instead of the other variations.  No change.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Here's a minimal test case that gets the same error:</p>
  
  <pre><code>import java.io.File;
  import java.util.Collection;
  
  class ResolutionProblem {
      static main(args) {
          Collection&lt;String&gt;  list = ["a", "b", "c", "d"];
          if (args.length &gt; 0) {
              File    file = new File(".")
              list.each {
                  owner.getYangFilesFromZip(file, list)
              }
          }
      }
  
      private Collection&lt;File&gt; getYangFilesFromZip(File file, Collection&lt;String&gt; excludeFiles) {
      }
  }
  </code></pre>