Bug 83615 - [1.5][compiler] lenient subclass checking with interdependent type variables
Summary: [1.5][compiler] lenient subclass checking with interdependent type variables
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-25 10:06 EST by Tom Hofmann CLA
Modified: 2005-02-15 07:21 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-01-25 10:06:40 EST
jdt-core of 20050125

the following snippet compiles, javac gives:

.../test1/DependentParameters.java:10: <Q,L>nextTry(Q,L) in
test1.DependentParameters cannot be applied to (java.lang.Integer,java.lang.Number)
		new DependentParameters().nextTry(i, n);
                ^
1 error

-------- snip ---------

package test1;

public class DependentParameters {

	public static void main(String[] args) {
		Number n= null;
		Integer i= null;
		new DependentParameters().nextTry(i, n);
	}	
	
	<Q,L extends Q> void nextTry(Q q, L l) {	
	}
	
}
Comment 1 Tom Hofmann CLA 2005-02-03 06:34:32 EST
Actually the solution eclipse finds seems correct as well - it resolves both Q
and L to java.lang.Number. This fulfills both "L extends Q" as well as "Integer
isa Number" and "Number isa Number" for the parameters.

Not sure what the spec says.
Comment 2 Philipe Mulet CLA 2005-02-03 07:02:56 EST
During type inference, we indeed infer that Q is Number and not Integer.
Comment 3 Philipe Mulet CLA 2005-02-04 06:35:04 EST
Unfortunately, spec says we should not be that clever. We did check the variable
bound (L extends Q) in first inference pass, to collect possible candidates; but
we should only consider doing so in a later stage, when there was no match for Q.

Comment 4 Philipe Mulet CLA 2005-02-07 10:27:49 EST
Adjusted type argument inference support to defer bound check to later stage. So
if candidate is found during method argument inference, it will prevail.

Added GenericTypeTest#test494.
Fixed
Comment 5 Jerome Lanneluc CLA 2005-02-15 07:21:56 EST
Verified in I20050214