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

Structural most specific fails when method reference is passed to overloaded method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 8
    • 8
    • tools
    • b82
    • Verified

    Description

      This program fails to compile:

      import java.util.*;
      import java.util.stream.*;

      class MostSpecific08 {
          
          static class C {
              int getInt() { return -1; }
              Integer getInteger() { return -1; }
          }
          
          void testMref(Stream<C> sp) {
              IntStream si_p = sp.map(C::getInt);
              Stream<Integer> si_r = sp.map(C::getInteger);
          }
          
          void testLambda(Stream<C> sp) {
              IntStream si_p = sp.map(c->c.getInt());
              Stream<Integer> si_r = sp.map(c->c.getInteger());
          }
      }

      class Test {
          void g(IntFunc i) { }
          void g(RefFunc i) { }

          void test() {
              g(Person::getAge);
          }
      }


      Attachments

        Activity

          People

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: