I've never used this way of coding myself, but I believe the issue is that you have a Function that returns a EvenPowerOfTwo, or one of its superclasses. And then you cast it to an EvenPowerOfTwo....