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

Default methods on closures coerced to interfaces don't work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.3.7
    • 2.3.8, 2.4.0-beta-4
    • None
    • None

    Description

      Seems like the default method doesn't get called, and a stub noop impl is used.

      import java.util.function.Consumer
      
      def consume(Consumer<String> consumer) {
        consumer
          .andThen({ println "2" })
          .accept("foo")
      }
      
      // Works
      consume(new Consumer<String>() { void accept(String s) { println "1" } })
       
      // Fails, andThen() returns null
      consume({ println "1" })
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            ldaley Luke Daley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: