James Johnson Jr wrote:Unfortunately, I don't quite understand why that would be an issue. My understanding is that Employee is a subclass of itself. So, if X is some subclass of Employee, then I'm not sure why it would be illegal to assign to X.
But
X could be
any subclass of
Employee.
Look at it another way. Would you expect the following to compile?
That's essentially what's happening - or at least, it could be, if
X is
CodeMonkey. The compiler will only allow things it can guarantee are type safe, and that means type safe for any valid value of
X.