groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (GROOVY-6888) Static type checking fails if I change the closure input parameter name
Date Tue, 06 Mar 2018 23:15:02 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-6888?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King closed GROOVY-6888.
-----------------------------

> Static type checking fails if I change the closure input parameter name
> -----------------------------------------------------------------------
>
>                 Key: GROOVY-6888
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6888
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.3.3, 2.4.0-beta-1, 2.4.0-rc-1
>            Reporter: Mauro Molinari
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 2.4.14
>
>
> Consider the following:
> {code}
> @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'
>   }
> }
> {code}
> The Groovy compiler fails:
> bq. [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).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message