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

15.12.2.1: Consider type parameter declarations for lambda potential compatibility

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: specification
    • Labels:

      Description

      Potential compatibility testing takes into account the arity of the targeted function type, but not the number of type parameters. Specifically, given a lambda argument, it would be possible to treat as incompatible all target function types that are generic. (Per 15.27.3, a lambda is never compatible with a generic function type.)

      Example:

         interface ConsumerA { <T> void accept(int i); }
         interface ConsumerB { void accept(int i); }
         void execute1(ConsumerA c) {}
         void execute1(ConsumerB c) {}

          execute1(x -> {}); // specified ambiguous, but could be disambiguated

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: