JDK-6284158 : Can't infer common supertype for String and Integer/int
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-06-10
  • Updated: 2010-04-02
  • Resolved: 2005-06-12
Related Reports
Duplicate :  
Description
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

Comments
WORK AROUND Object o1 = this.<Object,Integer,String>method(Integer.valueOf(1), "32"); Object o2 = this.<Object,Integer,String>method(1, "32"); ###@###.### 2005-06-10 19:37:53 GMT
10-06-2005