Bug 103485 - [1.5][compiler] compiler: wrongfully accepted method call
Summary: [1.5][compiler] compiler: wrongfully accepted method call
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
: 106284 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-07-12 10:12 EDT by Tom Hofmann CLA Friend
Modified: 2005-09-26 11:02 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA Friend 2005-07-12 10:12:09 EDT
3.1

- have the code below
- javac complains, ecj does not
- running the code produces a CCE in Integer.compareTo(Integer)

----- snip -----
class Hover {
	<T extends Comparable<T>> boolean isGreater(T t1, T t2) {
		return t1.compareTo(t2) > 0 ? true : false; 
	}

	void method(Integer i, Double d) {
		isGreater(i, d);
	}
}
----------------

----- javac output -----
javac 1.5.0_03
/opt/eclipse/workspaces/runtime/workbench/Article/src/com/example/Hover.java:14:
<T>isGreater(T,T) in com.example.Hover cannot be applied to
(java.lang.Integer,java.lang.Double)
		isGreater(i, d);
                ^
1 error
Comment 1 Tom Hofmann CLA Friend 2005-07-12 10:16:52 EDT
------- this fails correctly ----
	void method(Integer i, Double d) {
		Comparable<? extends Number> c1= i;
		Comparable<? extends Number> c2= d;
		isGreater(c1, c2);
	}
---------- and this warns correctly ----
	void method(Integer i, Double d) {
		Comparable c1= i;
		Comparable c2= d;
		isGreater(c1, c2);
	}
Comment 2 Philipe Mulet CLA Friend 2005-07-19 09:45:57 EDT
Problem comes from the fact an intersection type is handled as a wildcard when
performing bound check.

Fixed. Added GenericTypeTest#test790
Comment 3 Philipe Mulet CLA Friend 2005-08-08 10:19:30 EDT
*** Bug 106284 has been marked as a duplicate of this bug. ***
Comment 4 Maxime Daniel CLA Friend 2005-08-09 12:29:36 EDT
Opened bug 106514 to suggest an improvement of the error message. But since we
now have an error, this bug is Verified in 3.2 M1 with build I20050808-2000.
Comment 5 David Audel CLA Friend 2005-09-26 11:02:13 EDT
Verified using M20050923-1430 for 3.1.1