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

Can't infer common supertype for String and Integer/int

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • tools
    • None
    • generic
    • generic

      This program doesn't compile:

      abstract class A {
         abstract <S,A extends S, B extends S> S method(A la, B lb);

         void m2() {
            Object o1 = method(Integer.valueOf(1), "32");
            Object o2 = method(1, "32");
         }
      }


      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode)
       
      Test.java:5: <S,A,B>method(A,B) in A cannot be applied to (java.lang.Integer,java.lang.String)
            Object o1 = method(Integer.valueOf(1), "32");
                        ^
      Test.java:6: <S,A,B>method(A,B) in A cannot be applied to (int,java.lang.String)
            Object o2 = method(1, "32");
                        ^
      2 errors

      ###@###.### 2005-06-10 19:37:53 GMT

      See http://forum.java.sun.com/thread.jspa?threadID=635048&tstart=0

      ###@###.### 2005-06-10 19:38:28 GMT

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: