Covariant return types: can return a subtype of what is declared in your super. Example:
figure hereIs this okay? Why does it work? Because... A dog IS AN animal.
Definition: parametric polymorphism = polymorphic on a type which is parameter.
What does this mean about classes and types? Is a list of dogs a list of animals?
figure of UML of genericsNo because what if you put a cat in my list of dogs?
Syntax of GJ for generic classes and also limitations.
Now we have a list of data and we know the type, what about the accept method? It doesn't know what type the visitor wants, put it doesn't care. Its contract is that is won't touch what you pass along. Like wise with the return value.
Introduce generic methods Show the singleton hack. This doesn't occur in LRStruct nodes but it does happen in LRStruct state.