This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Problems with nested generics | ||
---|---|---|---|
Product: | java | Reporter: | nicolo <nicolo> |
Component: | Compiler | Assignee: | Dusan Balek <dbalek> |
Status: | RESOLVED WONTFIX | ||
Severity: | blocker | ||
Priority: | P4 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
nicolo
2008-01-08 07:16:33 UTC
Could you please try to find a small reproducible test case and attach it to this issue? Thanks. File Base.java public class Base { } File Model.java public class Model<B extends Base> { } File Contribution.java public abstract class Contribution <B extends Base, V, C extends Model<?>> extends Model<B> { public Contribution(){ } } File Manager.java public class Manager { public boolean createContribution(final Contribution<? extends Base, ?, ? extends Model<? extends Base>> contribution) { return false; } } File Main.java public class Main { public static void main (String[] args){ final Contribution <?, ?, ?> contr = new Contribution () {}; Manager man = new Manager(); if (man.createContribution(contr)){ //It shows the error here!!!!!!!!!!!!!!!!! System.out.println("Ciao"); } } } It shows an error: Incompatible types: required boolean, found createContribution. But it compiles and run Still reproducable with build 200910261401, although with a different error message. But external javac from JDK 1.6 also gives an error. There is a simple workaround though, just declare createContribution as: public boolean createContribution(final Contribution<?, ?, ?> contribution) It can be taken as a general coding rule that one shouldn't repeat type parameter bounds in wildcard arguments. For example it's redundant to write Model<? extends Base>, as the "extends Base" is already implicit in "Model<?>", because Model is defined as "Model<B extends Base>". Likewise, it's redundant to write "Contribution<? extends Base, ?, ? extends Model<? extends Base>>", because all these bounds are already implicit in "Contribution<?, ?, ?>". Of course javac should still be fixed to correctly recognize those equivalencies. This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss |