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

Static type checking fails if I change the closure input parameter name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3, 2.4.0-beta-1, 2.4.0-rc-1
    • 2.4.14
    • Static Type Checker
    • None

    Description

      Consider the following:

      @TypeChecked
      class A {
        @Bindable
        String foo
        
        static void main(String[] args) {
      	  A a = new A()
      	  a.foo = 'old'
      	  a.addPropertyChangeListener('foo') { event ->
      		  println 'foo changed: ' + event.oldValue + ' -> ' + event.newValue
      	  }
      	  a.foo = 'new'
        }
      }
      

      The Groovy compiler fails:

      [Static type checking] - No such property: oldValue for class: java.lang.Object

      This is unexpected, because if I leave the event naming of the closure input parameter and use it.oldValue/it.newValue the static type checking succeeds (as it should).

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: