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

15.12.2.5: Align check for unrelated functional interfaces with javac

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • specification

      Given two functional interface types S and T, S may be more specific than T if i) S <: T, or ii) T </: S and the two types' function types are appropriately related.

      The T </: S part of (ii) is necessary to prevent circularities in the relation -- if T <: S, it doesn't matter if T and S share similar (or, more likely, identical) function types, we're not going to let S be more specific than T. However, this restriction is narrower than might be intuitive: if T is *almost* a subtype, but not quite due to some subtle difference in, say, type arguments, users would prefer an error, rather than silently picking S.

      15.12.2.5 is also narrower than the check used in type inference (18.5.4), because in that case it's necessary to predict whether T will have a chance of being a subtype of S before generating any bounds -- there's a point where the algorithm has to decide whether (i) or (ii) is the appropriate path.

      15.12.2.5 is also narrower than javac in JDK 8.

      Proposal: unify 15.12.2.5, 18.5.4, and javac by settling on a straightforward definition of "related functional interface type", and only allow (ii) when the two types are not related.

            abuckley Alex Buckley
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: