Bug 110570 - [1.5][compiler] error in type deduction
Summary: [1.5][compiler] error in type deduction
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-26 05:19 EDT by Thomas Klaeger CLA
Modified: 2005-09-27 15:39 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Klaeger CLA 2005-09-26 05:19:00 EDT
In the following code Eclipse 3.2M2 reports an error on t1.test()

"The method test(Object, V1) in the type Tester is not applicable for the
arguments (A, B)"

whereas javac only reports an unchecked call.


IMHO the compiler should not report anything.

------------------------------------------------
public class Tester<T> {

  public <V1, V2 extends V1> void test(V1 p1, V2 p2) {}
	
  public static void main(String[] args) {
    A a = new A() {};
    B b = new B() {};

    Tester t1 = new Tester();
    t1.test(a, b); //this gives an error but should be OK
    
    Tester<Object> t2 = new Tester<Object>();
    t2.test(a, b); //this compiles OK
  }
}

interface A {
}
interface B extends A {
}
------------------------------------------------
Comment 1 Olivier Thomann CLA 2005-09-26 08:30:12 EDT
Reproduced with 3.2M2.
Comment 2 Philipe Mulet CLA 2005-09-26 10:42:31 EDT
Problem comes from improper substitution for raw type generic parameterized method. 

public <V1, V2 extends V1> void test(V1 p1, V2 p2) {}
ends up being:
void test(Object p1, V1 p2) 
due to incorrect use of variable strict upper bound.
It should instead consider variable erasure in raw form.

Added GenericTypeTest#test826-827.
Fixed both in 3.1.1 stream (> 3.1.1rc2) and HEAD
Comment 3 Olivier Thomann CLA 2005-09-27 15:39:04 EDT
Now it reports this warning.

The method test(Object, Object) belongs to the raw type Tester. References to
generic type Tester<T> should be parameterized	Tester.java

Verified in  M20050923-1430 + JDT/Core 3.1.1RC3 candidate