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

lub computes strange compound types

XMLWordPrintable

    • 5.0
    • 5.0
    • b67
    • generic, x86
    • generic, linux, windows_xp
    • Verified

      Steve Sides points out that the compiler generates a strange compound type for this program:

      interface I { }
      class X { }
      class A extends X implements I { }
      class B extends X implements I { }
      class Test {
          void test(A a, B b) {
      X x = (a.hashCode() == b.hashCode()) ? a : b;
          }
      }

      Test.java:7: incompatible types
      found : java.lang.Object&I&X
      required: X
              X x = (a.hashCode() == b.hashCode()) ? a : b;
                                                   ^
      1 error

      The compound type should have been X&I and the assignment should have succeded.

      ###@###.### 2004-07-30

            ahe Peter Ahe
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: