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

'this' in static context not treated as class by @CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.8, 2.1.3
    • 2.1.4
    • Static Type Checker
    • None

    Description

      This Groovy script fails to compile:

      @groovy.transform.CompileStatic
      class MyClass {
          static void main(String[] args) {
              println "Class loader: ${this.classLoader}"
          }
      }
      
      MyClass.main([] as String[])
      

      It complains that MyClass doesn't have a classLoader property. It seems that the static type checker does not treat this correctly in the context of a static method/property/initialiser.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: