Scott Murphy Heiberg created GROOVY-12675:
---------------------------------------------
Summary: MissingPropertyException for a closure suggests the
private field Closure.bcw
Key: GROOVY-12675
URL: https://issues.apache.org/jira/browse/GROOVY-12675
Project: Groovy
Issue Type: Bug
Affects Versions: 5.0.8, 4.0.33, 6.0.0, 7.0.0-alpha-1
Reporter: Scott Murphy Heiberg
{code:groovy}
def c = { -> 1 }
c.metaClass.getProperty(c, 'bar')
{code}
*Actual:*
{noformat}
groovy.lang.MissingPropertyException: No such property: bar for class:
Script1$_run_closure1
Possible solutions: bcw
{noformat}
In the same way, {{thisTyp}} suggests {{thisType}} and {{serialVersionUI}}
suggests {{serialVersionUID}}. {{c.metaClass.properties}} lists these and the
other private members of {{groovy.lang.Closure}}.
*Expected:* no suggestion of private members of {{Closure}}. A closure class
does not inherit them, and the metaclass of any other {{Closure}} subclass does
not list them.
Cause: {{ClosureMetaClass.getProperties}} returns the property list of the
metaclass of {{Closure}} itself, which includes Closure's own private fields
and properties. {{MethodRankHelper.getPropertySuggestionString}} ranks that
list for the "Possible solutions" text.
Verified on 4.0.33, 5.0.8, 6.0.0 and master.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)