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

Inference chokes on wildcard derived from method reference

    Details

    • Subcomponent:
    • Resolved In Build:
      b42
    • Verification:
      Verified

      Backports

        Description

        This will not compile:

            void test(Box<? extends Box<? extends Number>> b) {
                Number n = b.map(Box::get).get();
            }

            interface Func<S,T> { T apply(S arg); }

            interface Box<T> {
                T get();
                <R> Box<R> map(Func<T,R> f);
            }

        error: incompatible types: inferred type does not conform to upper bound(s)
                Number n = b.map(Box::get).get();
                                ^
            inferred: ? extends Number
            upper bound(s): Object

        If I remove the wildcards, there is no error.

        Perhaps javac is failing to capture the return type of Box.get?

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vromero Vicente Arturo Romero Zaldivar
                  Reporter:
                  dlsmith Dan Smith
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: