Bug 422503 - Eclipse incorrectly reporting bound mismatch on recursive generic types
Summary: Eclipse incorrectly reporting bound mismatch on recursive generic types
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-25 13:33 EST by Adam Augusta CLA
Modified: 2022-10-15 13:05 EDT (History)
3 users (show)

See Also:


Attachments
Test case. (6.39 KB, application/octet-stream)
2013-11-25 13:33 EST, Adam Augusta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Augusta CLA 2013-11-25 13:33:26 EST
Created attachment 237696 [details]
Test case.

I've included a test case demonstrating the issue. Given the following type signatures, I'm able to compile and run the code under Maven with both JDK 6 and JDK 7, but Eclipse gives a "Bound mismatch: The type F is not a valid substitute for the bounded parameter <F extends Field<TP,F>> of the type Field<TP,F>" error on both TupleVisitor and the anonymous implementation of TupleVisitor in SanityTest.java.

public abstract class Tuple<F extends Field<TP, F>, TP extends Tuple<F, TP>>

public class VariableTuple<F extends Field<VariableTuple<F>, F>> extends Tuple<F, VariableTuple<F>>

public class ConstantTuple<F extends Field<ConstantTuple<F>, F>> extends Tuple<F, ConstantTuple<F>>

public class Field<TP extends Tuple<F, TP>, F extends Field<TP, F>>

public static class ConstantField extends Field<ConstantTuple<ConstantField>, ConstantField>

public static class VariableField extends Field<VariableTuple<VariableField>, VariableField>

public interface TupleVisitor {
	public <F extends Field<VariableTuple<F>, F>> void visit(VariableTuple<F> tuple, F field);

	public <F extends Field<ConstantTuple<F>, F>> void visit(ConstantTuple<F> tuple, F field);
}
Comment 1 Adam Augusta CLA 2013-11-25 14:32:56 EST
Verified that issue also exists in 4.3.0.
Comment 3 Srikanth Sankaran CLA 2013-11-25 21:46:01 EST
As a first step, let us assess if this is a regression or a long standing
issue, so we will know where to slot this in relative to Java 8 work. Thanks.
Comment 4 Stephan Herrmann CLA 2013-11-28 11:42:03 EST
(In reply to Srikanth Sankaran from comment #3)
> As a first step, let us assess if this is a regression or a long standing
> issue, so we will know where to slot this in relative to Java 8 work. Thanks.

Bug has been present since 3.2.2.
Up-to 3.8 we reported three similar errors per method in TupleVisitor, starting with 4.3M5a we're down to one per method.
Apparently we have fixed something in that milestone, perhaps the fix just needs to be extended.
Comment 5 Stephan Herrmann CLA 2013-11-28 11:45:02 EST
(In reply to Stephan Herrmann from comment #4)
> [...]
> starting with 4.3M5a we're down to one per method.
> Apparently we have fixed something in that milestone,

Likely candidate: bug 395002.
Comment 6 Stephan Herrmann CLA 2016-08-09 12:15:45 EDT
Still occurs with 4.7 M1, reported errors are:

----------
1. ERROR in /tmp/sandbox/src/main/java/org/roxton/TupleVisitor.java (at line 4)
        public <F extends Field<VariableTuple<F>, F>> void visit(VariableTuple<F> tuple, F field);
                                              ^
Bound mismatch: The type F is not a valid substitute for the bounded parameter <F extends Field<VariableTuple<F>,F>> of the type VariableTuple<F>
----------
2. ERROR in /tmp/sandbox/src/main/java/org/roxton/TupleVisitor.java (at line 6)
        public <F extends Field<ConstantTuple<F>, F>> void visit(ConstantTuple<F> tuple, F field);
                                              ^
Bound mismatch: The type F is not a valid substitute for the bounded parameter <F extends Field<ConstantTuple<F>,F>> of the type ConstantTuple<F>
----------
2 problems (2 errors)
Comment 7 Manoj N Palat CLA 2018-05-17 03:25:31 EDT
bulk move out of 4.8
Comment 8 Eclipse Genie CLA 2022-10-15 13:05:30 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.