Bug 148046 - [compiler][1.5] should raise an incompatible types error when a given type variable cannot fulfill its bounds
Summary: [compiler][1.5] should raise an incompatible types error when a given type va...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-21 10:41 EDT by Maxime Daniel CLA
Modified: 2007-10-29 08:36 EDT (History)
0 users

See Also:


Attachments
Proposed patch (4.86 KB, patch)
2007-10-10 07:26 EDT, Philipe Mulet CLA
no flags Details | Diff
Better patch (5.35 KB, patch)
2007-10-10 07:45 EDT, Philipe Mulet CLA
no flags Details | Diff
Additional change (4.87 KB, patch)
2007-10-10 10:09 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2006-06-21 10:41:33 EDT
Version: 3.2.0
Build id: I20060614-0843

In GenericTypeTest#550, which is copied below for clarity, U must extend B and honor a lower bound of A. But B extends A, hence U cannot satisfy all its bounds, and javac 1.5.0_08 and 6.0 b86 both raise an error. Eclipse only raises an unchecked warning.

class A {}
class B extends A {}
public class X<T> {
	public <U extends B> void foo(X<? super A> param) {
		X<U> foo = (X<U>) param; // unchecked warning vs error
	}
}
Comment 1 Philipe Mulet CLA 2006-10-08 10:24:46 EDT
Cast checks are spec'ed to tolerate such situations where both types are not provably distinct.

javac doesn't follow the spec here; but I admit their behavior is more helpful as statically the cast could be rejected based on bound constraints.

Need to decide whether we bet on spec to evolve in javac direction or we stick to the spec.
Comment 2 Philipe Mulet CLA 2007-01-10 06:45:27 EST
Other symptoms in bug 120088.
Comment 3 Philipe Mulet CLA 2007-01-10 06:45:50 EST
Also see bug 170064.
Comment 4 Philipe Mulet CLA 2007-10-10 07:23:58 EDT
Added GenericTypeTest#test1193
Comment 5 Philipe Mulet CLA 2007-10-10 07:26:02 EDT
Created attachment 80032 [details]
Proposed patch
Comment 6 Philipe Mulet CLA 2007-10-10 07:28:33 EDT
Tuned GenericTypeTest#test0550
Comment 7 Philipe Mulet CLA 2007-10-10 07:45:56 EDT
Created attachment 80034 [details]
Better patch
Comment 8 Philipe Mulet CLA 2007-10-10 07:51:31 EDT
Released for 3.4M3.
Fixed
Comment 9 Philipe Mulet CLA 2007-10-10 10:09:28 EDT
Created attachment 80043 [details]
Additional change

Required to avoid some regression in classlibs (java/lang/Class)
Comment 10 Philipe Mulet CLA 2007-10-10 10:09:51 EDT
Released for 3.4M3.
Fixed
Comment 11 Maxime Daniel CLA 2007-10-29 08:36:54 EDT
Verified for 3.4 M3 using build I20071029-0010.