[ https://issues.apache.org/jira/browse/GROOVY-11299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17812400#comment-17812400 ]
Eric Milles edited comment on GROOVY-11299 at 2/27/24 5:53 PM: --------------------------------------------------------------- https://github.com/apache/groovy/commit/482a229754c65fc36e387fa59f509e343dfdbd49 https://github.com/apache/groovy/commit/710ff9e7b4e195b35ec5ff8b506783394221876a https://github.com/apache/groovy/commit/d58386b31a57779225f088ee5bf39f5a2949fd36 was (Author: emilles): https://github.com/apache/groovy/commit/482a229754c65fc36e387fa59f509e343dfdbd49 https://github.com/apache/groovy/commit/710ff9e7b4e195b35ec5ff8b506783394221876a > ClassNode getField(String), getMethods(String) and others return from super > interface when class uses extends > ------------------------------------------------------------------------------------------------------------- > > Key: GROOVY-11299 > URL: https://issues.apache.org/jira/browse/GROOVY-11299 > Project: Groovy > Issue Type: Bug > Reporter: Eric Milles > Assignee: Eric Milles > Priority: Major > Labels: traits > Fix For: 5.0.0-alpha-6 > > > Consider the following: > {code:groovy} > trait A { > def m() {} > } > trait B extends A { > } > {code} > Calling {{ClassNode#getMehtod(String)}} before the canonicalization compile > phase returns "m()". Normally a super-trait or super-interface method would > not be returned -- when appearing in the {{implements}} clause for example. > The test cases of GROOVY-8272 and GROOVY-10312 are examples of where this > comes up. > {code:groovy} > trait A { > static sm() { > 'A' > } > } > trait B extends A { > String m() { > sm().toLowerCase() > } > } > class C implements B { > } > print(new C().m()) > {code} > {{StaticImportVisitor}} runs during semantic analysis before the trait > transform has moved {{A}} from super class to super interface. Asking for > the methods "sm" of {{B}} returns the method of {{A}} and so "sm()" is > transformed into the static call "B.sm()". Leaving the method call unchanged > allows it to be resolved through other trait means and fixes 8272, 10312 > without dynamic dispatch (of trait helpers) that was added in Groovy 5. -- This message was sent by Atlassian Jira (v8.20.10#820010)