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

Inference regression with JDK 8 and -source 7

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: tools
    • Labels:

      Description

      This program doesn't compile when source is set to a value other than 8 (the example is a bit more verbose than necessary, to get better output):

      interface Bar<X extends Bar<X>> { }

      class Test {
          <A extends Bar<A>> void test() {
              A result = m();
          }

      <B extends Bar<B>> B m() {
              return null;
          }
      }

      Error:

      /opt/JDK/8/re/b40/bin/javac -source 7 Main.java
      Main.java:7: error: incompatible types: inferred type does not conform to upper bound(s)
              A result = m();
                          ^
          inferred: B
          upper bound(s): Bar<B>,A
        where B,A are type-variables:
          B extends A
          A extends Bar<A> declared in method <A>test()
      1 error

      Compiling w/o the -source flag, or with a JDK 7 compiler works w/o issues.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: