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

Closures are incorrectly coerced if a method call is done inside a closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.2.0
    • 2.2.1
    • None
    • None

    Description

      The following test case demonstrates the problem:

      Class foo(Runnable r) {
          // please do not remove wrapping inside a closure
          // because that's precisely what this test is supposed to check!
          { -> bar(r) }()
      }
      
      Class bar(Runnable r) {
         r.class
      }
      
      assert Closure.isAssignableFrom(foo { 'Hello' })
      

      The assertion fails, with the class being a Proxy, which implies coercion to Runnable, which is implemented by Closure was involved.

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: