Bug 169728 - [1.5][compiler] WildcardBinding.boundCheck coding error
Summary: [1.5][compiler] WildcardBinding.boundCheck coding error
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.3 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-05 16:40 EST by Eric Inman CLA
Modified: 2007-04-27 05:01 EDT (History)
0 users

See Also:


Attachments
Proposed patch (5.16 KB, patch)
2007-03-29 08:04 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 Eric Inman CLA 2007-01-05 16:40:45 EST
For multiple bounds, returns true if only one of the bounds is satisfied rather than requiring all of the bounds to be satisfied. The comment indicates that all of the bounds must be satisfied, and JLS3 15.12.2.7, p. 465 seems to indicate that as well.
Comment 1 Philipe Mulet CLA 2007-01-08 06:13:54 EST
I think we have another bug for this. Need to isolate a simple testcase.
Comment 2 Philipe Mulet CLA 2007-03-28 09:33:25 EDT
I think I was relating to a different issue in comment 1.

Pls provide a testcase for suspected issue.
The following is correctly handled with 3.3M6:

public class X<T extends Comparable<T> & Runnable> {

	public static void main(String[] args) {
		
		X<OnlyRunnable> x1 = null; // error
		X<OnlyComparable> x2 = null; // error
		X<ComparableRunnable> x3 = null; // ok
	}
}

abstract class OnlyRunnable implements Runnable {}
abstract class OnlyComparable implements Comparable<OnlyComparable> {}
abstract
Comment 3 Philipe Mulet CLA 2007-03-28 09:34:04 EDT
Oops, testcase got truncated.

public class X<T extends Comparable<T> & Runnable> {

	public static void main(String[] args) {
		
		X<OnlyRunnable> x1 = null; // error
		X<OnlyComparable> x2 = null; // error
		X<ComparableRunnable> x3 = null; // ok
	}
}

abstract class OnlyRunnable implements Runnable {}
abstract class OnlyComparable implements Comparable<OnlyComparable> {}
abstract class ComparableRunnable implements Comparable<ComparableRunnable>, Runnable {}
Comment 4 Eric Inman CLA 2007-03-28 11:02:34 EDT
(In reply to comment #3)

This test case above is also correctly handled with 3.2.0.

It looks like the problem is just with the comment.

x.boundCheck(y) apparently means y is compatible with x, in which case y must be compatible with at least one of the bounds of x, not with all of them as the comment states.
Comment 5 Philipe Mulet CLA 2007-03-28 12:44:09 EDT
Yes, this is my opinion too. For wildcards, the check is easier, since it relies on the fact that no offending type could be built anyway (and fed to the wildcard).

Comment 6 Philipe Mulet CLA 2007-03-29 08:03:48 EDT
Fixed offending comment.
Added GenericTypeTest#test1119 proving that current behavior is enforced.
Comment 7 Philipe Mulet CLA 2007-03-29 08:04:05 EDT
Created attachment 62376 [details]
Proposed patch
Comment 8 Jerome Lanneluc CLA 2007-04-27 05:01:48 EDT
Verified for 3.3M7 with I20070427-0010