Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5106

Same interface can be implemented with two different generic types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.0-beta-3
    • 4.0.0
    • Compiler
    • None

    Description

      Given the following 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()
      

      The "One" interface is implemented twice with two different generic types, which should not be allowed. Here's another example, more complex :

      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> {
      
      }
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              melix Cédric Champeau
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: