You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/02/03 22:36:00 UTC
[jira] [Closed] (GROOVY-5106) Same interface can be implemented with two different generic types
[ https://issues.apache.org/jira/browse/GROOVY-5106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-5106.
-----------------------------
> Same interface can be implemented with two different generic types
> ------------------------------------------------------------------
>
> Key: GROOVY-5106
> URL: https://issues.apache.org/jira/browse/GROOVY-5106
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 2.4.0-beta-3
> Reporter: Cédric Champeau
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0
>
>
> Given the following code :
> {code}
> interface One<T> {
> void echo(T obj);
> }
> interface Two extends One<String> {}
> class OneImpl implements Two,One<Integer> {
> public void echo(String obj) { println obj }
> }
> def o = new OneImpl()
> {code}
> The "One" interface is implemented twice with two different generic types, which should not be allowed. Here's another example, more complex :
> {code}
> interface Transcoder<T, U> {
> T transcode(U obj);
> }
> interface TranscoderToString<V> extends Transcoder<String, V>{
> }
> abstract class AbstractToStringTranscoder<V> implements TranscoderToString<V> {
> public String transcode(final V obj) {
> return obj.toString();
> }
> }
> class IntegerToStringTranscoder extends AbstractToStringTranscoder<Integer> implements TranscoderToString<Boolean> {
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)