[ https://issues.apache.org/jira/browse/GROOVY-6663?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17762498#comment-17762498 ]
Eric Milles commented on GROOVY-6663: ------------------------------------- Since {{getText(String)}} in B is a covariant override, there is also {{getText(Object)}} generated as a bridge. When passing {{null}}, the bridge method makes a closer match. You can avoid this by inserting a typecast: {code:groovy} class C extends B { @Override protected String getText(String string) { super.getText((String) string) } } {code} In order for the compiler/runtime to avoid this without your intervention, it could insert this cast or it needs to implement "String super$3$getText(Object object) \{ super.getText((String) object) \}". This MOP method is not generated due to a check for bridge methods in MopWriter#visitMopMethodList. MetaClassImpl ends up with "super$3$getText(String)" from C and "super$2$getText(Object)" from B. It chooses the latter without the typecast and that's why you see it skip over B and run the A method. Again, this is only for null -- a string argument is routed properly. > Incorrect order of calling super.method when depth more than two and first > class is generic > ------------------------------------------------------------------------------------------- > > Key: GROOVY-6663 > URL: https://issues.apache.org/jira/browse/GROOVY-6663 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.2.1, 2.4.0-rc-1 > Environment: Java 7 > Reporter: Aleh Bich > Assignee: Eric Milles > Priority: Major > > I have following code: > {code:title=A.groovy} > package test.groovy > class A<T> { > protected String getText(T arg){ > System.out.println( "A does something else"); > return "Class A. -> "; > } > } > {code} > {code:title=B.groovy} > package test.groovy > class B extends A<String> { > @Override > protected String getText(String arg) { > System.out.println("B does something else"); > return super.getText(arg) + "Class B. -> "; > } > } > {code} > {code:title=C.groovy} > package test.groovy > class C extends B { > @Override > protected String getText(String arg) { > System.out.println("C does something else"); > return super.getText(arg) + "Class C. "; > } > public static void main(String[] args) { > def c = new C() > println(c.getText(null)) > } > } > {code} > I expected to receive next result: > {code:title=Expected output} > C does something else > B does something else > A does something else > Class A. -> Class B. -> Class C. > {code} > But got the following output: > {code:title=Actual output} > C does something else > A does something else > Class A. -> Class C. > {code} > This issue might have same cause and can duplicate [GROOVY-6653 > issue|https://jira.codehaus.org/browse/GROOVY-6653]. -- This message was sent by Atlassian Jira (v8.20.10#820010)