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

STC: error for non-static member of class delegate

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.21, 5.0.0-alpha-8, 4.0.21
    • 5.0.0-alpha-9
    • Static Type Checker
    • None

    Description

      Consider the following:

      class Foo {
        static getBar() { 'bar' }
        Object getBaz() { 'baz' }
      }
      
      @groovy.transform.TypeChecked
      void test() {
        def foo = Foo
        foo.with {
          println bar
          println baz
          println getBar()
          println getBaz()
        }
      }
      
      test()
      

      This script prints "bar" and then throws a MissingPropertyException or ClassCastException (static compilation). The type checker does not warn of non-static member access for a Class delegate.

      GROOVY-9415, GROOVY-9618, GROOVY-10820

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: