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

When static type checking, only static invocations to methods, not to variables, are considered

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0.5
    • None
    • Static Type Checker
    • None
    • Windows XP, groovy 2.0.5

    Description

      In the following code (and the same code is attached), two lines are printed out, which is what one should expect.
      Alas, after uncommenting the @TypeChecked annotation, two (similar) errors are listed:

      [Static type checking] - Cannot find matching method java.lang.Class#v(groovy.lang.Closure <java.lang.Void>). Please check if the declared type is right and if the method exists.
      

      This is the code in question:

      import groovy.transform.TypeChecked
      class A {
         static v = { it() }
         static main(args) {
            new A().m()
         }
         //@TypeChecked
         def m() { 
            A.v() { println 'ok A.' }
            B.v() { println 'ok B.' }
         }
      }
      class B  {
         static v = { it() }
      }
      

      Attachments

        1. A.groovy
          0.3 kB
          Stach Rosik

        Activity

          People

            blackdrag Jochen Theodorou
            stach Stach Rosik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: