| Summary: | JDT Compiler accept type without wilcard | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Roman Wieser <wza> |
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | srikanth_sankaran |
| Version: | 3.5.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | stalebug | ||
Javac5,6,7 all reject this code snippet with the message shown in comment# 0. Eclipse has been compiling this code without any issues at least as of 3.3.2, probably forever. See that in this modified scenario, we report an error and match javac's behavior: class FooImpl<X extends CharSequence> {} class OtherClass <X> {} class B extends FooImpl {} public class Exec { void foo(OtherClass<? extends FooImpl<?>> p) {} void bar(OtherClass<B> p) { foo(p); } } the error message being: "The method foo(OtherClass<? extends FooImpl<?>>) in the type Exec is not applicable for the arguments (OtherClass<B>)" If the test is modified so suitable bounds are used instead of the raw type as in: class FooImpl<X extends CharSequence> {} class OtherClass <X> {} class B extends FooImpl<String> {} public class Exec { void foo(OtherClass<? extends FooImpl<?>> p) {} void bar(OtherClass<B> p) { foo(p); } } both javac and eclipse are happy and compile the code without any complaints. 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. |
Build Identifier: 20100218-1602 Source Code: ---------------------------------------- public interface IFoo<T> {} class FooImpl<X extends CharSequence> implements IFoo<X> {} // removing <?> is fine class SomeClass<S extends FooImpl<?>> {} class Exec { // adding <?> to FooImpl is ok public <A extends FooImpl> void test() { new SomeClass<A>(); } } ---------------------------------------------- Eclipse compiles this code without any complain. The Sun Compiler (1.6.0.15) shows the error: --------------------------------- IFoo.java:12: type parameter A is not within its bound new SomeClass<A>(); ^ 1 error ---------------------------------- Reproducible: Always Steps to Reproduce: copy code and compile it with Eclipse or sun jdk