Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8008627

Compiler mishandles three-way return-type-substitutability

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • tools
    • None
    • b96
    • generic
    • generic
    • Verified

    Description

      This fails to compile:

      ---

       interface I {
         Object m(Iterable l);
       }

       interface J<S> {
         S m(Iterable<String> l);
       }

       interface K<T> {
         T m(Iterable<String> l);
       }

       interface Functional<S,T> extends I, J<S>, K<T> {}

      ---

      On the other hand, this compiles fine:

      ---

      interface Parent<T> {
         T m(Iterable<String> i);
       }

       interface Child<T> extends Parent<T> {
         Object m(Iterable i);
       }

      ---

      This compiles fine, too:

      ---

      interface I {
         int[] m(Iterable l);
       }

       interface J<S> {
         java.io.Serializable m(Iterable<String> l);
       }

       interface K<T> {
         Cloneable m(Iterable<String> l);
       }

       interface Functional<S,T> extends I, J<S>, K<T> {}

      ---
       
      Problem appears to be that javac is looking for pairwise return-type-substitutable when it uses the rule "R1 = |R2|", while JLS 9.4.1 just says that there needs to be one method RTS for all the others.

      Attachments

        Activity

          People

            mcimadamore Maurizio Cimadamore
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: