GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1143

Type inference support for DGM methods

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.1Release
    • Fix Version/s: 2.5.2.Release
    • Component/s: Inferencing Engine
    • Labels:
      None
    • Number of attachments :
      2

      Description

      The following snippets do not recognize the static type of the lists in side the supplied closures:

      [1, 2].countBy { it.intValue() }
      
      [1, 2].count { it.intValue() } 
      

        Activity

        Hide
        Bob Tiernay added a comment -

        Also, the following also does not infer the type of list inside the closure:

        [1, 2].findResult { it.intValue() }
        
        Show
        Bob Tiernay added a comment - Also, the following also does not infer the type of list inside the closure: [1, 2].findResult { it.intValue() }
        Hide
        Bob Tiernay added a comment -

        Also, the following does not infer the type of list inside the closure:

        [1, 2].any { it.intValue() }
        
        Show
        Bob Tiernay added a comment - Also, the following does not infer the type of list inside the closure: [1, 2].any { it.intValue() }
        Hide
        Bob Tiernay added a comment -

        A couple more

        [1, 2].grep { it.intValue() } 
        
        [1, 2].split { it.intValue() }
        
        Show
        Bob Tiernay added a comment - A couple more [1, 2].grep { it.intValue() } [1, 2].split { it.intValue() }
        Hide
        Bob Tiernay added a comment -

        And

        [1, 2].removeAll { it.intValue() }
        
        [1, 2].retainAll { it.intValue() }
        
        Show
        Bob Tiernay added a comment - And [1, 2].removeAll { it.intValue() } [1, 2].retainAll { it.intValue() }
        Hide
        Bob Tiernay added a comment -

        And

        [1, 2].inject(0) { i, value -> i.intValue() + value.intValue() }
        
        Show
        Bob Tiernay added a comment - And [1, 2].inject(0) { i, value -> i.intValue() + value.intValue() }
        Hide
        Bob Tiernay added a comment -

        And

        [1, 2].sum { it.intValue() }
        
        Show
        Bob Tiernay added a comment - And [1, 2].sum { it.intValue() }
        Hide
        Andrew Eisenberg added a comment -

        Fixed with regression tests.

        Show
        Andrew Eisenberg added a comment - Fixed with regression tests.
        Hide
        Bob Tiernay added a comment -

        It seems as though any still has issues:

        [1, 2].any { it.intValue() }
        
        Show
        Bob Tiernay added a comment - It seems as though any still has issues: [1, 2].any { it.intValue() }
        Hide
        Bob Tiernay added a comment -

        The following methods don't infer types as well:

        [1, 2].findIndexOf { it.intValue() }
        [1, 2].findIndexOf(1) { it.intValue() }
        [1, 2].findIndexValues { it.intValue() }
        [1, 2].findIndexValues(1) { it.intValue() }
        [1, 2].findLastIndexOf { it.intValue() }
        [1, 2].findLastIndexOf(1) { it.intValue() }
        [1, 2].collectAll { it.intValue() }
        [1, 2].min { it.intValue()  }
        [1, 2].max { it.intValue()  }
        
        Show
        Bob Tiernay added a comment - The following methods don't infer types as well: [1, 2].findIndexOf { it.intValue() } [1, 2].findIndexOf(1) { it.intValue() } [1, 2].findIndexValues { it.intValue() } [1, 2].findIndexValues(1) { it.intValue() } [1, 2].findLastIndexOf { it.intValue() } [1, 2].findLastIndexOf(1) { it.intValue() } [1, 2].collectAll { it.intValue() } [1, 2].min { it.intValue() } [1, 2].max { it.intValue() }
        Hide
        Andrew Eisenberg added a comment -

        Thanks for being so thorough about this. I'll get to it tomorrow.

        Show
        Andrew Eisenberg added a comment - Thanks for being so thorough about this. I'll get to it tomorrow.
        Hide
        Bob Tiernay added a comment -

        And some more:

        1.identity { it.intValue() }
        [1, 2].flatten { it.intValue() }
        1.times { it.intValue() }
        1.upto(2 ) { it.intValue() }
        2.downto(1 ) { it.intValue() }
        1.step( 1, 2 ) { it.intValue() }
        new File("test").withObjectOutputStream { it.close() }
        new File("test").withObjectInputStream { it.close() }
        "".eachLine { it.toUpperCase() }
        "".eachLine(0) { it.toUpperCase() }
        new File("test").eachLine { it.toUpperCase() }
        new File("test").eachLine("UTF8") { it.toUpperCase() }
        "".splitEachLine("test") { it.toUpperCase() }
        "".splitEachLine(~/test/) { it.toUpperCase() }
        new File(".").eachFile { it.getName() }
        new File(".").eachDir { it.getName() }
        new File(".").eachFileRecurse(null) { it.getName() }
        new File(".").eachFileRecurse() { it.getName() }
        new File(".").eachDirRecurse() { it.getName() }
        new File(".").traverse() { it.getName() }
        new File(".").traverse([:]) { it.getName() }
        

        Is there anyway to automate this?

        Show
        Bob Tiernay added a comment - And some more: 1.identity { it.intValue() } [1, 2].flatten { it.intValue() } 1.times { it.intValue() } 1.upto(2 ) { it.intValue() } 2.downto(1 ) { it.intValue() } 1.step( 1, 2 ) { it.intValue() } new File( "test" ).withObjectOutputStream { it.close() } new File( "test" ).withObjectInputStream { it.close() } "".eachLine { it.toUpperCase() } "".eachLine(0) { it.toUpperCase() } new File( "test" ).eachLine { it.toUpperCase() } new File( "test" ).eachLine( "UTF8" ) { it.toUpperCase() } "".splitEachLine(" test") { it.toUpperCase() } "".splitEachLine(~/test/) { it.toUpperCase() } new File( "." ).eachFile { it.getName() } new File( "." ).eachDir { it.getName() } new File( "." ).eachFileRecurse( null ) { it.getName() } new File( "." ).eachFileRecurse() { it.getName() } new File( "." ).eachDirRecurse() { it.getName() } new File( "." ).traverse() { it.getName() } new File( "." ).traverse([:]) { it.getName() } Is there anyway to automate this?
        Hide
        Bob Tiernay added a comment -

        Groovy script that will generate a set of type inference tests for DGM to stdout

        Show
        Bob Tiernay added a comment - Groovy script that will generate a set of type inference tests for DGM to stdout
        Hide
        Bob Tiernay added a comment -

        Slightly enhanced to handle more argument types

        Show
        Bob Tiernay added a comment - Slightly enhanced to handle more argument types
        Hide
        Andrew Eisenberg added a comment -

        Thanks for the script. It does show all the methods that we need to handle. However, as far as I can tell there is no way of automating this discovery in the IDE. In the static type information of the closure parameter of the DGM, the heuristic is simple: the parameter type is the same type as self, or if self is a collection, then extract the type parameter of the collection and look at that. But there are also special cases, such as eachWithIndex that take an extra argument and other methods, like each that depend also on the number of closure arguments.

        Adding new rules is not complicated, but there is no way of determining what the special cases are without hard-coding them.

        Show
        Andrew Eisenberg added a comment - Thanks for the script. It does show all the methods that we need to handle. However, as far as I can tell there is no way of automating this discovery in the IDE. In the static type information of the closure parameter of the DGM, the heuristic is simple: the parameter type is the same type as self , or if self is a collection, then extract the type parameter of the collection and look at that. But there are also special cases, such as eachWithIndex that take an extra argument and other methods, like each that depend also on the number of closure arguments. Adding new rules is not complicated, but there is no way of determining what the special cases are without hard-coding them.
        Hide
        Andrew Eisenberg added a comment -

        Fixed, again.

        Show
        Andrew Eisenberg added a comment - Fixed, again.
        Hide
        Bob Tiernay added a comment -

        There still seems to be some issues with the 2.1.3.xx-20110808-1500-e37 release in this regard:

        
        // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.min(java.util.Map,groovy.lang.Closure)
        [key:1].min { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.min(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).min { it.intValue() }
        
        // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.max(java.util.Map,groovy.lang.Closure)
        [key:1].max { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.max(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).max { it.intValue() }
        
        // Type inference test of public static java.lang.Number org.codehaus.groovy.runtime.DefaultGroovyMethods.count(java.util.Map,groovy.lang.Closure)
        [key:1].count { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Number org.codehaus.groovy.runtime.DefaultGroovyMethods.count(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).count { it.intValue() }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceAll(java.lang.String,java.lang.String,groovy.lang.Closure)
        "".replaceAll("") { it.toLowerCase() }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceAll(java.lang.String,java.util.regex.Pattern,groovy.lang.Closure)
        "".replaceAll(~/test/) { it.toLowerCase() }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceFirst(java.lang.String,java.lang.String,groovy.lang.Closure)
        "".replaceFirst("") { it.toLowerCase() }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceFirst(java.lang.String,java.util.regex.Pattern,groovy.lang.Closure)
        "".replaceFirst(~/test/) { it.toLowerCase() }
        
        // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.find(java.util.Map,groovy.lang.Closure)
        [key:1].find { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.util.Map,groovy.lang.Closure)
        [key:1].sort { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object[] org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).sort { it.intValue() }
        
        // Type inference test of public static java.lang.Object[] org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.lang.Object[],boolean,groovy.lang.Closure)
        ([1] as Object[]).sort(true) { it.intValue() }
        
        // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.removeAll(java.util.Collection,groovy.lang.Closure)
        [1].removeAll { it.intValue() }
        
        // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.retainAll(java.util.Collection,groovy.lang.Closure)
        [1].retainAll { it.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.addShutdownHook(java.lang.Object,groovy.lang.Closure)
        1.addShutdownHook { it.intValue() }
        
        // Type inference test of public static java.net.Socket org.codehaus.groovy.runtime.DefaultGroovyMethods.accept(java.net.ServerSocket,groovy.lang.Closure) throws java.io.IOException
        new ServerSocket().accept { it.getPort() }
        
        // Type inference test of public static java.net.Socket org.codehaus.groovy.runtime.DefaultGroovyMethods.accept(java.net.ServerSocket,boolean,groovy.lang.Closure) throws java.io.IOException
        new ServerSocket().accept(true) { it.getPort() }
        
        // Type inference test of public static groovy.lang.MetaClass org.codehaus.groovy.runtime.DefaultGroovyMethods.metaClass(java.lang.Class,groovy.lang.Closure)
        Integer.metaClass { methods }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.with(java.lang.Object,groovy.lang.Closure)
        1.with { it.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.use(java.lang.Object,java.lang.Class,groovy.lang.Closure)
        1.use(Integer) { it.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.use(java.lang.Object,java.util.List,groovy.lang.Closure)
        1.use([1]) { it.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(java.util.Map,groovy.lang.Closure)
        [key:1].eachWithIndex { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.reverseEach(java.util.Map,groovy.lang.Closure)
        [key:1].reverseEach { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object[] org.codehaus.groovy.runtime.DefaultGroovyMethods.reverseEach(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).reverseEach { it.intValue() }
        
        // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.every(java.util.Map,groovy.lang.Closure)
        [key:1].every { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.any(java.util.Map,groovy.lang.Closure)
        [key:1].any { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.List org.codehaus.groovy.runtime.DefaultGroovyMethods.collectNested(java.util.Collection,groovy.lang.Closure)
        [1].collectNested { it.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectNested(java.util.Collection,java.util.Collection,groovy.lang.Closure)
        [1].collectNested([1]) { it.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.util.Collection,groovy.lang.Closure)
        [1].collectMany { it.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).collectMany { it.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.util.Iterator,groovy.lang.Closure)
        [1].iterator().collectMany { it.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.collectEntries(java.lang.Object[],java.util.Map,groovy.lang.Closure)
        ([1] as Object[]).collectEntries([key:1]) { it.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.collectEntries(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).collectEntries { it.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.findResult(java.util.Map,java.lang.Object,groovy.lang.Closure)
        [key:1].findResult(1) { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.findResult(java.util.Map,groovy.lang.Closure)
        [key:1].findResult { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.findResults(java.util.Collection,groovy.lang.Closure)
        [1].findResults { it.intValue() }
        
        // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.findResults(java.util.Map,groovy.lang.Closure)
        [key:1].findResults { it.getKey().toUpperCase() + it.getValue().intValue() }
        [key:1].findResults { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(java.util.Map,groovy.lang.Closure)
        [key:1].findAll { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.groupBy(java.util.Map,groovy.lang.Closure)
        [key:1].groupBy { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.countBy(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).countBy { it.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.countBy(java.util.Map,groovy.lang.Closure)
        [key:1].countBy { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.groupEntriesBy(java.util.Map,groovy.lang.Closure)
        [key:1].groupEntriesBy { it.getKey().toUpperCase() + it.getValue().intValue() }
        [key:1].groupEntriesBy { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.inject(java.util.Map,java.lang.Object,groovy.lang.Closure)
        [key:1].inject(1) { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.inject(java.lang.Object[],java.lang.Object,groovy.lang.Closure)
        ([1] as Object[]).inject(1) { value, item -> value.intValue() + item.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.sum(java.lang.Object[],groovy.lang.Closure)
        ([1] as Object[]).sum { it.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.sum(java.lang.Object[],java.lang.Object,groovy.lang.Closure)
        ([1] as Object[]).sum(1) { it.intValue() }
        
        // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.withDefault(java.util.Map,groovy.lang.Closure)
        [key:1].withDefault { it.getKey().toUpperCase() + it.getValue().intValue() }
        [key:1].withDefault { key, value -> key.toUpperCase() + value.intValue() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(java.io.OutputStream,groovy.lang.Closure) throws java.io.IOException
        new FileOutputStream(new File("test")).withStream { it.write(1) }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachObject(java.io.File,groovy.lang.Closure) throws java.io.IOException,java.lang.ClassNotFoundException
        new File("test").eachObject { it.getName() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachObject(java.io.ObjectInputStream,groovy.lang.Closure) throws java.io.IOException,java.lang.ClassNotFoundException
        new ObjectInputStream(new FileInputStream("test")).eachObject { it.read() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachFileMatch(java.io.File,groovy.io.FileType,java.lang.Object,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException
        new File("test").eachFileMatch(FileType.FILES, 1) { it.getName() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachFileMatch(java.io.File,java.lang.Object,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException
        new File("test").eachFileMatch(1) { it.getName() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachDirMatch(java.io.File,java.lang.Object,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException
        new File("test").eachDirMatch(1) { it.getName() }
        
        // Type inference test of public static java.util.TimerTask org.codehaus.groovy.runtime.DefaultGroovyMethods.runAfter(java.util.Timer,int,groovy.lang.Closure)
        new Timer().runAfter(1) new Timer()
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withReader { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.File,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new File("test").withReader("") { it.reset()}
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.Reader,groovy.lang.Closure) throws java.io.IOException
        new FileReader(new File("test")).withReader { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.net.URL,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").withReader { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.net.URL,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").withReader("") { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.InputStream,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).withReader { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.InputStream,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).withReader("") { it.reset() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withOutputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withOutputStream { it.flush() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withInputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withInputStream { it.available() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withInputStream(java.net.URL,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").withInputStream { it.available() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withDataOutputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withDataOutputStream { it.flush() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withDataInputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withDataInputStream { it.readUTF() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withWriter { it.getName() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.File,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new File("test").withWriter("") { it.getName() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileWriter(new File("test")).withWriter { it.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.OutputStream,groovy.lang.Closure) throws java.io.IOException
        new FileOutputStream(new File("test")).withWriter { it.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.OutputStream,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new FileOutputStream(new File("test")).withWriter("") { it.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriterAppend(java.io.File,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new File("test").withWriterAppend("") { it.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriterAppend(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").withWriterAppend { it.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withPrintWriter(java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileWriter(new File("test")).withPrintWriter { it.write(1) }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").eachByte { it.getName() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.File,int,groovy.lang.Closure) throws java.io.IOException
        new File("test").eachByte(1) { it.getName() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.lang.Byte[],groovy.lang.Closure)
        ([1] as Byte[]).eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(byte[],groovy.lang.Closure)
        ([1] as byte[]).eachByte {buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.InputStream,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.InputStream,int,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).eachByte(1) { buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.net.URL,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.net.URL,int,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").eachByte(1) { buffer, bytesRead -> buffer.size() + bytesRead.intValue() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.transformChar(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileReader(new File("test")).transformChar(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.transformLine(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileReader(new File("test")).transformLine(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileReader(new File("test")).filterLine(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,groovy.lang.Closure) throws java.io.IOException
        new File("test").filterLine { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new File("test").filterLine("") { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new File("test").filterLine(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.io.Writer,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new File("test").filterLine(new FileWriter(new File("test")), "") { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.Reader,groovy.lang.Closure)
        new FileReader(new File("test")).filterLine { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,groovy.lang.Closure)
        new FileInputStream(new File("test")).filterLine { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.lang.String,groovy.lang.Closure) throws java.io.UnsupportedEncodingException
        new FileInputStream(new File("test")).filterLine("") { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).filterLine(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.io.Writer,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new FileInputStream(new File("test")).filterLine(new FileWriter(new File("test")), "") { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").filterLine { it.toUpperCase() }
        
        // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").filterLine("") { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.io.Writer,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").filterLine(new FileWriter(new File("test"))) { it.toUpperCase() }
        
        // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.io.Writer,java.lang.String,groovy.lang.Closure) throws java.io.IOException
        new URL("http://www.google.com").filterLine(new FileWriter(new File("test")), "") { it.toUpperCase() }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withStreams(java.net.Socket,groovy.lang.Closure) throws java.io.IOException
        new Socket().withStreams { is, os -> is.read(); os.write(1) }
        
        // Type inference test of public static java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withObjectStreams(java.net.Socket,groovy.lang.Closure) throws java.io.IOException
        new Socket().withObjectStreams { is, os -> is.read(); os.write(1) }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.eachMatch(java.lang.String,java.lang.String,groovy.lang.Closure)
        "".eachMatch("") { it.toLowerCase() }
        
        // Type inference test of public static java.lang.String org.codehaus.groovy.runtime.DefaultGroovyMethods.eachMatch(java.lang.String,java.util.regex.Pattern,groovy.lang.Closure)
        "".eachMatch(~/test/) { it.toLowerCase() }
        
        
        Show
        Bob Tiernay added a comment - There still seems to be some issues with the 2.1.3.xx-20110808-1500-e37 release in this regard: // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.min(java.util.Map,groovy.lang.Closure) [key:1].min { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.min(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).min { it.intValue() } // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.max(java.util.Map,groovy.lang.Closure) [key:1].max { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.max(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).max { it.intValue() } // Type inference test of public static java.lang. Number org.codehaus.groovy.runtime.DefaultGroovyMethods.count(java.util.Map,groovy.lang.Closure) [key:1].count { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Number org.codehaus.groovy.runtime.DefaultGroovyMethods.count(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).count { it.intValue() } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceAll(java.lang. String ,java.lang. String ,groovy.lang.Closure) "".replaceAll(" ") { it.toLowerCase() } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceAll(java.lang. String ,java.util.regex.Pattern,groovy.lang.Closure) "".replaceAll(~/test/) { it.toLowerCase() } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceFirst(java.lang. String ,java.lang. String ,groovy.lang.Closure) "".replaceFirst(" ") { it.toLowerCase() } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.replaceFirst(java.lang. String ,java.util.regex.Pattern,groovy.lang.Closure) "".replaceFirst(~/test/) { it.toLowerCase() } // Type inference test of public static java.util.Map$Entry org.codehaus.groovy.runtime.DefaultGroovyMethods.find(java.util.Map,groovy.lang.Closure) [key:1].find { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.util.Map,groovy.lang.Closure) [key:1].sort { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object [] org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).sort { it.intValue() } // Type inference test of public static java.lang. Object [] org.codehaus.groovy.runtime.DefaultGroovyMethods.sort(java.lang. Object [], boolean ,groovy.lang.Closure) ([1] as Object []).sort( true ) { it.intValue() } // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.removeAll(java.util.Collection,groovy.lang.Closure) [1].removeAll { it.intValue() } // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.retainAll(java.util.Collection,groovy.lang.Closure) [1].retainAll { it.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.addShutdownHook(java.lang. Object ,groovy.lang.Closure) 1.addShutdownHook { it.intValue() } // Type inference test of public static java.net.Socket org.codehaus.groovy.runtime.DefaultGroovyMethods.accept(java.net.ServerSocket,groovy.lang.Closure) throws java.io.IOException new ServerSocket().accept { it.getPort() } // Type inference test of public static java.net.Socket org.codehaus.groovy.runtime.DefaultGroovyMethods.accept(java.net.ServerSocket, boolean ,groovy.lang.Closure) throws java.io.IOException new ServerSocket().accept( true ) { it.getPort() } // Type inference test of public static groovy.lang.MetaClass org.codehaus.groovy.runtime.DefaultGroovyMethods.metaClass(java.lang. Class ,groovy.lang.Closure) Integer .metaClass { methods } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.with(java.lang. Object ,groovy.lang.Closure) 1.with { it.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.use(java.lang. Object ,java.lang. Class ,groovy.lang.Closure) 1.use( Integer ) { it.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.use(java.lang. Object ,java.util.List,groovy.lang.Closure) 1.use([1]) { it.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(java.util.Map,groovy.lang.Closure) [key:1].eachWithIndex { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.reverseEach(java.util.Map,groovy.lang.Closure) [key:1].reverseEach { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object [] org.codehaus.groovy.runtime.DefaultGroovyMethods.reverseEach(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).reverseEach { it.intValue() } // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.every(java.util.Map,groovy.lang.Closure) [key:1].every { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static boolean org.codehaus.groovy.runtime.DefaultGroovyMethods.any(java.util.Map,groovy.lang.Closure) [key:1].any { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.List org.codehaus.groovy.runtime.DefaultGroovyMethods.collectNested(java.util.Collection,groovy.lang.Closure) [1].collectNested { it.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectNested(java.util.Collection,java.util.Collection,groovy.lang.Closure) [1].collectNested([1]) { it.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.util.Collection,groovy.lang.Closure) [1].collectMany { it.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).collectMany { it.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.collectMany(java.util.Iterator,groovy.lang.Closure) [1].iterator().collectMany { it.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.collectEntries(java.lang. Object [],java.util.Map,groovy.lang.Closure) ([1] as Object []).collectEntries([key:1]) { it.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.collectEntries(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).collectEntries { it.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.findResult(java.util.Map,java.lang. Object ,groovy.lang.Closure) [key:1].findResult(1) { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.findResult(java.util.Map,groovy.lang.Closure) [key:1].findResult { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.findResults(java.util.Collection,groovy.lang.Closure) [1].findResults { it.intValue() } // Type inference test of public static java.util.Collection org.codehaus.groovy.runtime.DefaultGroovyMethods.findResults(java.util.Map,groovy.lang.Closure) [key:1].findResults { it.getKey().toUpperCase() + it.getValue().intValue() } [key:1].findResults { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(java.util.Map,groovy.lang.Closure) [key:1].findAll { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.groupBy(java.util.Map,groovy.lang.Closure) [key:1].groupBy { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.countBy(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).countBy { it.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.countBy(java.util.Map,groovy.lang.Closure) [key:1].countBy { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.groupEntriesBy(java.util.Map,groovy.lang.Closure) [key:1].groupEntriesBy { it.getKey().toUpperCase() + it.getValue().intValue() } [key:1].groupEntriesBy { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.inject(java.util.Map,java.lang. Object ,groovy.lang.Closure) [key:1].inject(1) { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.inject(java.lang. Object [],java.lang. Object ,groovy.lang.Closure) ([1] as Object []).inject(1) { value, item -> value.intValue() + item.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.sum(java.lang. Object [],groovy.lang.Closure) ([1] as Object []).sum { it.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.sum(java.lang. Object [],java.lang. Object ,groovy.lang.Closure) ([1] as Object []).sum(1) { it.intValue() } // Type inference test of public static java.util.Map org.codehaus.groovy.runtime.DefaultGroovyMethods.withDefault(java.util.Map,groovy.lang.Closure) [key:1].withDefault { it.getKey().toUpperCase() + it.getValue().intValue() } [key:1].withDefault { key, value -> key.toUpperCase() + value.intValue() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withStream(java.io.OutputStream,groovy.lang.Closure) throws java.io.IOException new FileOutputStream( new File( "test" )).withStream { it.write(1) } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachObject(java.io.File,groovy.lang.Closure) throws java.io.IOException,java.lang.ClassNotFoundException new File( "test" ).eachObject { it.getName() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachObject(java.io.ObjectInputStream,groovy.lang.Closure) throws java.io.IOException,java.lang.ClassNotFoundException new ObjectInputStream( new FileInputStream( "test" )).eachObject { it.read() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachFileMatch(java.io.File,groovy.io.FileType,java.lang. Object ,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException new File( "test" ).eachFileMatch(FileType.FILES, 1) { it.getName() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachFileMatch(java.io.File,java.lang. Object ,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException new File( "test" ).eachFileMatch(1) { it.getName() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachDirMatch(java.io.File,java.lang. Object ,groovy.lang.Closure) throws java.io.FileNotFoundException,java.lang.IllegalArgumentException new File( "test" ).eachDirMatch(1) { it.getName() } // Type inference test of public static java.util.TimerTask org.codehaus.groovy.runtime.DefaultGroovyMethods.runAfter(java.util.Timer, int ,groovy.lang.Closure) new Timer().runAfter(1) new Timer() // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withReader { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.File,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withReader("") { it.reset()} // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.Reader,groovy.lang.Closure) throws java.io.IOException new FileReader( new File( "test" )).withReader { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.net.URL,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).withReader { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.net.URL,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).withReader("") { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.InputStream,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).withReader { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withReader(java.io.InputStream,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).withReader("") { it.reset() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withOutputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withOutputStream { it.flush() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withInputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withInputStream { it.available() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withInputStream(java.net.URL,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).withInputStream { it.available() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withDataOutputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withDataOutputStream { it.flush() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withDataInputStream(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withDataInputStream { it.readUTF() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withWriter { it.getName() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.File,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withWriter("") { it.getName() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileWriter( new File( "test" )).withWriter { it.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.OutputStream,groovy.lang.Closure) throws java.io.IOException new FileOutputStream( new File( "test" )).withWriter { it.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriter(java.io.OutputStream,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new FileOutputStream( new File( "test" )).withWriter("") { it.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriterAppend(java.io.File,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withWriterAppend("") { it.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withWriterAppend(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).withWriterAppend { it.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withPrintWriter(java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileWriter( new File( "test" )).withPrintWriter { it.write(1) } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).eachByte { it.getName() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.File, int ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).eachByte(1) { it.getName() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.lang. Byte [],groovy.lang.Closure) ([1] as Byte []).eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte( byte [],groovy.lang.Closure) ([1] as byte []).eachByte {buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.InputStream,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.io.InputStream, int ,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).eachByte(1) { buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.net.URL,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).eachByte { buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(java.net.URL, int ,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).eachByte(1) { buffer, bytesRead -> buffer.size() + bytesRead.intValue() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.transformChar(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileReader( new File( "test" )).transformChar( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.transformLine(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileReader( new File( "test" )).transformLine( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.Reader,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileReader( new File( "test" )).filterLine( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,groovy.lang.Closure) throws java.io.IOException new File( "test" ).filterLine { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).filterLine("") { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new File( "test" ).filterLine( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.File,java.io.Writer,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new File( "test" ).filterLine( new FileWriter( new File( "test" )), "") { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.Reader,groovy.lang.Closure) new FileReader( new File( "test" )).filterLine { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,groovy.lang.Closure) new FileInputStream( new File( "test" )).filterLine { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.lang. String ,groovy.lang.Closure) throws java.io.UnsupportedEncodingException new FileInputStream( new File( "test" )).filterLine("") { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).filterLine( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.io.InputStream,java.io.Writer,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new FileInputStream( new File( "test" )).filterLine( new FileWriter( new File( "test" )), "") { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).filterLine { it.toUpperCase() } // Type inference test of public static groovy.lang.Writable org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).filterLine("") { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.io.Writer,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).filterLine( new FileWriter( new File( "test" ))) { it.toUpperCase() } // Type inference test of public static void org.codehaus.groovy.runtime.DefaultGroovyMethods.filterLine(java.net.URL,java.io.Writer,java.lang. String ,groovy.lang.Closure) throws java.io.IOException new URL( "http: //www.google.com" ).filterLine( new FileWriter( new File( "test" )), "") { it.toUpperCase() } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withStreams(java.net.Socket,groovy.lang.Closure) throws java.io.IOException new Socket().withStreams { is, os -> is.read(); os.write(1) } // Type inference test of public static java.lang. Object org.codehaus.groovy.runtime.DefaultGroovyMethods.withObjectStreams(java.net.Socket,groovy.lang.Closure) throws java.io.IOException new Socket().withObjectStreams { is, os -> is.read(); os.write(1) } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.eachMatch(java.lang. String ,java.lang. String ,groovy.lang.Closure) "".eachMatch(" ") { it.toLowerCase() } // Type inference test of public static java.lang. String org.codehaus.groovy.runtime.DefaultGroovyMethods.eachMatch(java.lang. String ,java.util.regex.Pattern,groovy.lang.Closure) "".eachMatch(~/test/) { it.toLowerCase() }
        Hide
        Bob Tiernay added a comment -

        Can we change the title of this issue to "Type inference support for DGM methods" to more accurately reflect the totality of the issue? Thanks

        Show
        Bob Tiernay added a comment - Can we change the title of this issue to "Type inference support for DGM methods" to more accurately reflect the totality of the issue? Thanks
        Hide
        Andrew Eisenberg added a comment -

        Some more work to do.

        Show
        Andrew Eisenberg added a comment - Some more work to do.
        Hide
        Andrew Eisenberg added a comment -

        Fixed everything that I will for this issue. Some of the lines above do not seem to be valid groovy code and some entries were incorrect.

        I will add tests for each of this.

        Show
        Andrew Eisenberg added a comment - Fixed everything that I will for this issue. Some of the lines above do not seem to be valid groovy code and some entries were incorrect. I will add tests for each of this.

          People

          • Assignee:
            Andrew Eisenberg
            Reporter:
            Bob Tiernay
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: