You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Mykhailo Nesterenko (JIRA)" <ji...@apache.org> on 2018/02/28 17:05:00 UTC

[jira] [Commented] (GROOVY-7891) Possible Problem With Closures Calling Private Methods In A Trait

    [ https://issues.apache.org/jira/browse/GROOVY-7891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16380668#comment-16380668 ] 

Mykhailo Nesterenko commented on GROOVY-7891:
---------------------------------------------

could someone shed some light on this issue?

> Possible Problem With Closures Calling Private Methods In A Trait
> -----------------------------------------------------------------
>
>                 Key: GROOVY-7891
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7891
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.5
>            Reporter: Jeff Scott Brown
>            Priority: Major
>
> It looks like a closure defined in a trait does not have access to private methods defined in the trait.  I am not sure if this is broken or not.
> {code}
> trait SomeTrait {
>     void somePublicMethod() {
>         def someClosure = {
>             somePrivateMethod()
>         }
>         someClosure()
>     }
>     private void somePrivateMethod() {}
> }
> {code}
> {code}
> class Demo implements SomeTrait {
>     static void main(args) {
>         new Demo().somePublicMethod()
>     }
> }
> {code}
> {code}
> $ groovy Demo
> Caught: groovy.lang.MissingMethodException: No signature of method: Demo.somePrivateMethod() is applicable for argument types: (Demo) values: [Demo@2473d930]
> groovy.lang.MissingMethodException: No signature of method: Demo.somePrivateMethod() is applicable for argument types: (Demo) values: [Demo@2473d930]
> 	at SomeTrait$Trait$Helper$_somePublicMethod_closure1.doCall(SomeTrait.groovy:5)
> 	at SomeTrait$Trait$Helper$_somePublicMethod_closure1.doCall(SomeTrait.groovy)
> 	at SomeTrait$Trait$Helper.somePublicMethod(SomeTrait.groovy:7)
> 	at SomeTrait$Trait$Helper$somePublicMethod.call(Unknown Source)
> 	at Demo.somePublicMethod(Demo.groovy)
> 	at SomeTrait$somePublicMethod.call(Unknown Source)
> 	at Demo.main(Demo.groovy:3)
> {code}
> Please advise.  Thanks for the input.
> https://github.com/grails/grails-core/issues/10060



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