I'm going to use a slight problem I've found with IDEA to ask an OT question about generics in case anyone can help :)
I have something like the hierarchy in the attached file - I couldn't paste it here, sorry, I couldn't figure out how to make the forums format it correctly. It's a hierarchy for creating graphs - there's a series of related interfaces (Nodes have Ports, which connect them to Edges). There are various different classes of Nodes (BaseNode in this example) and each class has various specific types (SpecificNode). A given graph will only have a particular class of node, but will have many specific types (all derived from BaseNode, for example). I wanted to type the hierarchy so that the code for SpecificNode will get back a list of Port when it calls getPorts, for example. To do this I had to type all the interfaces as shown. Edge is not typed (since it goes between two nodes of different types), but the getFrom method allows the caller to specify the type it expects, I'm happy with a couple of unchecked warnings in the Edge class.
This all works swimmingly until you start trying to use these collections in a generic way. The code shown appears as correct in IDEA but the compiler chokes:
GenericsTest.java:23: inconvertible types
found : GenericsTest.Port>
return (Port) fromPort;
GenericsTest.java:58: incompatible types
found : GenericsTest.Node
BaseNode>]]> baseNode = from.getNode();
Any idea why IntelliJ is not picking up this error while I edit? I've also found it's not very clever about completing type parameters, I can't use Ctrl Shift Space to get a list of potential matches, either with or without a wildcard restriction. And any clever suggestions about how I might redesign the hierarchy to allow me type safety but not be endlessly fighting with the compiler? I'm just about ready to take out all my changes and just cast everywhere.
Thanks in advance,