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.

Bug 124864 - Problems with nested generics
Summary: Problems with nested generics
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker with 3 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-08 07:16 UTC by nicolo
Modified: 2016-07-07 07:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nicolo 2008-01-08 07:16:33 UTC
if I have a class Class1<B> and another class Class2<B, V, C>, and a class Class3 with a method
 public boolean meth(final Class2<? extends B, ?, ? extends Class1<? extends B>>); when I call the method meth from an
other class the editor shows me an error message: "incompatible types: found Class3.meth, required boolean"
The compiler works, but the editor shows me the error
Comment 1 Jan Lahoda 2008-01-15 06:30:33 UTC
Could you please try to find a small reproducible test case and attach it to this issue? Thanks.
Comment 2 nicolo 2008-01-15 08:09:51 UTC
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
Comment 3 matthies 2009-10-30 19:38:23 UTC
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.
Comment 4 Martin Balin 2016-07-07 07:18:38 UTC
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