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

Eric Milles edited comment on GROOVY-8587 at 2/28/24 6:35 PM:
--------------------------------------------------------------

https://github.com/apache/groovy/commit/cef3a2c1d0d59ccd1071e155df8ea133fbb813c2
https://github.com/apache/groovy/commit/d3b40a85654401b82d9607158bf3bb297f5d0289


was (Author: emilles):
https://github.com/apache/groovy/commit/cef3a2c1d0d59ccd1071e155df8ea133fbb813c2\
https://github.com/apache/groovy/commit/d3b40a85654401b82d9607158bf3bb297f5d0289

> Calling super in an overridden method results in MissingMethodException when 
> method indirectly inherited from trait
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8587
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8587
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.15
>            Reporter: Jonathan Cottrill
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: traits
>             Fix For: 5.0.0-alpha-2
>
>
> Consider the following:
> {code:groovy}
> trait A {
>     void doSomething() {
>         println "A"
>     }
> }
> trait B extends A {}
> class C implements B {
>     @Override
>     void doSomething() {
>         B.super.doSomething()
>     }
>     static void main(String[] args) {
>         new C().doSomething()
>     }
> }
> {code}
> Although this compiles fine, a MissingMethodException is thrown at runtime:
> {code}
> Exception in thread "main" groovy.lang.MissingMethodException: No signature 
> of method: static B.doSomething() is applicable for argument types: (C) 
> values: [C@12f41634]
>       at 
> groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1518)
>       at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
>       at 
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:921)
>       at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:181)
>       at B$Trait$Helper.$static_methodMissing(Bug.groovy)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
>       at 
> groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1516)
>       at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1504)
>       at 
> org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
>       at C.doSomething(Bug.groovy:12)
>       at A$doSomething.call(Unknown Source)
>       at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>       at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
>       at C.main(Bug.groovy:16)
> {code}
> There appears to be no way to override a method from a trait that was 
> implemented in a "supertrait" and delegate to the original implementation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to