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

Verify error in class annotated with @Category if instance field is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.2.0-beta-1
    • None

    Description

      The following code fails with Verify error

      @Mixin(Foo)
      class Bar {}
      
      @Category(Bar)
      class Foo {
          public x = 5
      
          def foo() {
              print x //verify error because of the field reference
          }
      }
      
      new Bar().foo()
      

      But if we use field 'x' outside of 'Foo' no errors happen

      @Mixin(Foo)
      class Bar {}
      
      @Category(Bar)
      class Foo {
          public x = 5
      
          def foo() {
          }
      }
      
      new Bar().x = 4
      print new Bar().x //prints 5
      

      So imho the first code snippet should not throw the error.

      Attachments

        Activity

          People

            melix Cédric Champeau
            mxm-groovy Maxim Medvedev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: