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

AIC in Closure is checked for wrong constructor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3
    • 2.3.4
    • Static Type Checker
    • None

    Description

      interface X {
          def m()
      }
      
      @groovy.transform.CompileStatic
      class A {
          Object pm = "pm"
      
          def bar(Closure<? exends X> x) {x().m()}
          def foo() {
              bar { ->
                  return new X() {
                      def m() {
                          print pm.getClass().getSimpleName()
                      }
                  }
              }
          }
      }
      

      This fails with

      Cannot call A$1#<init>(groovy.lang.Closure) with arguments [A]

      and

      Cannot find matching method A#bar(groovy.lang.Closure <A$1>). Please check if the declared type is right and if the method exists.

      but it should work

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            blackdrag Jochen Theodorou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: