LazyOptional is just a lazily-instantiated Optional.
It still holds a value, that value is of type T. T as in LazyOptional<T>
That value gets cast to T when you call someLazy.cast(), so if the value actually stored in the LazyOptional is not actually of type T, the cast will fail.
Optionals are just a box wrapped around a concrete object because you don't know if that object actually exists or not (which is why you have to use ifPresent, orElse, or orElseThrow--depending on circumstances).