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

15.12.2.1: Consider type parameter declarations for lambda potential compatibility

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 8
    • specification

      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

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

              Created:
              Updated: