Bug 74119 - [1.5] Unexpected compile error with bound types with Eclipse 3.1M1.
Summary: [1.5] Unexpected compile error with bound types with Eclipse 3.1M1.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 74178 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-16 16:46 EDT by Carsten Langer CLA
Modified: 2004-12-14 12:14 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Langer CLA 2004-09-16 16:46:15 EDT
Acutally I report this against Eclipse 3.1M1, but Bugzilla didn't let me 
specify this.

For the following test file, the line (1) does compile using Sun's JDK1.5.0RC, 
but not using Eclipse 3.1M1. The compiler error for "visit" is: "The method 
visit(? super Test.I) in the type Test.Visitor<? super Test.I> is not 
applicable for the arguments (Test.C)".

In my opinion is should compile. The line (2) is a workaround.

Please check and fix such that line (1) compiles.

class Test {
    static interface I extends Visitible<I> {
    }

    static interface Visitible<T> {
        void acceptVisitor(Visitor<? super T> visitor);
    }
    
    static interface Visitor<T> {
        void visit(T t);
    }

    static class C implements I {
        public void acceptVisitor(Visitor<? super I> visitor) {
            visitor.visit(this); // (1) Compilable with Sun JDK1.5.0RC, but not
                                 // with Eclipse3.1M1
            visitor.visit((I) this); // (2) This is a workaround
        }
    }
}
Comment 1 Philipe Mulet CLA 2004-11-08 09:58:04 EST
Fixed by changing Wildcard#boundCheck to allow SUPER scenario to tolerate
subtype as well (since could be cast to uppertype).

Added regression test: GenericTypeTest#test300 + test395.
Comment 2 Philipe Mulet CLA 2004-11-10 11:24:17 EST
Fixed
Comment 3 Philipe Mulet CLA 2004-11-10 11:35:35 EST
*** Bug 74178 has been marked as a duplicate of this bug. ***
Comment 4 Olivier Thomann CLA 2004-12-14 12:14:52 EST
Verified in 200412140800