[
https://issues.apache.org/jira/browse/GROOVY-8788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17582550#comment-17582550
]
Eric Milles commented on GROOVY-8788:
-------------------------------------
6. mixed declaration and extension (pt.2)
{code:groovy}
class A { int m(String s) {4} }
class B extends A { }
class C extends B { }
class Ext {
static m(B self, Object o) {2}
}
use (Ext) {
def a = new A()
assert a.m(new String()) == 4
def b = new B()
assert b.m(new Object()) == 2
assert b.m(new String()) == 4
def c = new C()
assert c.m(new Object()) == 2
assert c.m(new String()) == 4
}
{code}
This case behaves under dynamic and static compilation. So no change required.
:)
> Inconsistency in extension method selection with @CompileStatic
> ---------------------------------------------------------------
>
> Key: GROOVY-8788
> URL: https://issues.apache.org/jira/browse/GROOVY-8788
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 2.4.15, 2.5.2
> Reporter: Daniil Ovchinnikov
> Assignee: Eric Milles
> Priority: Major
> Labels: breaking
>
> Given properly registered extension class:
> {code:java|title=MyExtensions.java}
> public class MyExtensions {
> public static void foo(Object self, String s) {
> System.out.println("Object#foo(String)");
> }
> public static void foo(String self, Object o) {
> System.out.println("String#foo(Object)");
> }
> }
> {code}
> Run
> {code:java|title=playground.groovy}
> void usageExt() {
> "".foo("") // prints "Object#foo(String)" which is correct
> }
> @groovy.transform.CompileStatic
> void usageExtStatic() {
> "".foo("") // prints "String#foo(Object)" which is questionable
> }
> usageExt()
> usageExtStatic()
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)