[
https://issues.apache.org/jira/browse/GROOVY-8098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149120#comment-18149120
]
Daniel Sun commented on GROOVY-8098:
------------------------------------
Fixed on master; added a regression test in
16de8fa504866a4adf9b74722590a3d4c361c634
(https://github.com/apache/groovy/commit/16de8fa504866a4adf9b74722590a3d4c361c634).
> Methods overloading issue
> -------------------------
>
> Key: GROOVY-8098
> URL: https://issues.apache.org/jira/browse/GROOVY-8098
> Project: Groovy
> Issue Type: Bug
> Reporter: Agata Strojewska
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 7.0.0-alpha-1
>
>
> I've created a repository on Github with a simple example showing the
> problem: https://github.com/astrojewska/groovy-overloading-issue
> There is a base repository interface with generic types:
> {code:title=BaseRepository.java|borderStyle=solid}
> public interface BaseRepository<T, S extends Serializable> {
> void call(T t);
> void call(S s);
> }
> {code}
> And the specified:
> {code:title=BaseSpecializedRepo.java|borderStyle=solid}
> public interface BaseSpecializedRepo extends BaseRepository<Integer, String> {
> }
> {code}
> Then I've created a class that implements BaseRepository<T, S>:
> {code:title=InMemoryBaseRepo.java|borderStyle=solid}
> public class InMemoryBaseRepo<T, S extends Serializable> implements
> BaseRepository<T, S> {
> public void call(T t) {
> System.out.println("T call");
> }
> public void call(S s) {
> System.out.println("S call");
> }
> }
> {code}
> And another class that extends the previous one (in groovy):
> {code:title=InMemorySpecializedGroovyRepo.groovy|borderStyle=solid}
> class InMemorySpecializedGroovyRepo extends InMemoryBaseRepo<Integer, String>
> implements BaseSpecializedRepo {
> }
> {code}
> Now I try to instantiate InMemorySpecializedGroovyRepo:
> {code}
> BaseSpecializedRepo groovyRepo = new InMemorySpecializedGroovyRepo()
> {code}
> And call:
> {code}
> groovyRepo.call(new Integer(0));
> groovyRepo.call(new String("empty"));
> {code}
> At this point always method for <T> generic type is called.
> Output:
> {code}
> ### GROOVY ###
> T call
> T call
> // java implementation: BaseSpecializedRepo javaRepo = new
> InMemorySpecializedJavaRepo()
> ### JAVA ###
> T call
> S call
> {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)