Bug 85262 - [1.5] Bound mismatch: type R is not a valid substitute for the bounded parameter...
Summary: [1.5] Bound mismatch: type R is not a valid substitute for the bounded param...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-15 09:42 EST by Jan Schäfer CLA
Modified: 2005-03-31 08:39 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 Jan Schäfer CLA 2005-02-15 09:42:51 EST
This bug is similar to the already verified fixed bug #62822. 
 
The following test case produces the error message: 
 
Bound mismatch: The type R is not a valid substitute for  
the bounded parameter <R extends Foo<R>> of the type Bar<R> 
 
Note that if you do a clean and a build it works, but as soon as you change  
the FooImpl.java file and save it again, the error message appears. 
 
---------------------- 
Test case: 
 
public interface Bar<R extends Foo<R>>  {} 
 
public class BarImpl<R extends Foo<R>>  
       implements Bar<R> {} 
 
public interface Foo<R extends Foo<R>>  
       extends Bar<R> {} 
 
public class FooImpl<R extends Foo<R>>  
       extends BarImpl<R> implements Foo<R> {}
Comment 1 Jan Schäfer CLA 2005-02-16 04:20:09 EST
I have forgotten where exactly the error appears. 
In the FooImpl.java file: 
 
public class FooImpl<R extends Foo<R>>   
       extends BarImpl<R> implements Foo<R> {} 
-------------------------------------^^^ 
 
Comment 2 Philipe Mulet CLA 2005-02-23 07:13:02 EST
Reproduced only in incremental mode; that is when FooImpl is compiled
independantly from the rest (either direclty by touching it, or indirectly when
adding a signature to one of its referenced types).

Problem would thus lie in some generated parameter bound lying in required
classfile.

Added GenericTypeTest#test519-520.
Comment 3 Philipe Mulet CLA 2005-02-23 07:23:54 EST
Actually problem rather probably lives in lazy supertype resolution.
After renaming type parameters to better see what is going on:
interface Bar<R extends Foo<R>>  {} 
class BarImpl<S extends Foo<S>> implements Bar<S> {} 
interface Foo<T extends Foo<T>> extends Bar<T> {} 
class FooImpl<U extends Foo<U>> extends BarImpl<U> implements Foo<U> {}

----------
1. ERROR in FooImpl.java (at line 1)
	public class FooImpl<U extends Foo<U>> extends BarImpl<U> implements Foo<U> {}
	                                                                     ^^^
Bound mismatch: The type T is not a valid substitute for the bounded parameter
<R extends Foo<R>> of the type Bar<R>
----------

There seems to be some confusion, as variable T shouldn't be considered when
resolving FooImpl hierarchy, it should only see substituted form with U. 
Comment 4 Kent Johnson CLA 2005-03-09 16:43:43 EST
Fixed.

Needed to change Scope.substitute() so it didn't answer Binary types as 
replacements for Parameterized types.
Comment 5 David Audel CLA 2005-03-31 08:39:08 EST
Verified in I20050330-0500