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

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.1
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: