groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-5106) Same interface can be implemented with two different generic types
Date Sun, 26 Aug 2018 02:45:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-5106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16592757#comment-16592757
] 

Paul King commented on GROOVY-5106:
-----------------------------------

Java/Intellij would give an error message like:
{noformat}
One cannot be inherited with different type arguments: <java.lang.String> and <java.lang.Integer>
{noformat}


> 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
>            Priority: Major
>
> 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
(v7.6.3#76005)

Mime
View raw message