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

Static scope error for variable in non-static method of static inner class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.14, 3.0.8, 4.0.0-alpha-3
    • 2.5.15, 4.0.0-beta-1, 3.0.9
    • None
    • None

    Description

      Similar to GROOVY-9678, bean-style property accesses in static inner class may be improperly flagged as an unresolved static reference. Consider the following:

      class A {
        def getB() {
          'works'
        }
      }
      class C {
        @Mixin(A)
        static class D {
          void test() {
            println b
          }
        }
      }
      new C.D().test()
      

      Access to mixin method "getB()" through the variable expression is flagged with "Apparent variable 'b' was found in a static scope but doesn't refer to a local variable, static field or class." If "b" is written as "getB()" or "this.b" the script compiles and executes as expected.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m