-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check class type parameter variance violations in inheritance #736
Comments
Seems like we break this in our own tests but fixing the |
I have this done on a branch, will submit PR later when my other stuff related to variance is in (since fixing this depends on fixing variance in general) |
It just struck me that we should reject things like |
Yeah, I'm sure there's a research paper that goes through all the special cases. Some of these might be relevant, in case you want to dig deeper (warning greek alert): http://research.microsoft.com/en-us/um/people/akenn/generics/ |
In generic inheritance, we can't change the variance of a type from invariant to covariant/contravariant. This should probably be rejected:
Going from covariant to invariant is fine (for example,
List
has to do this since it subclassesSequence
, which is covariant).The text was updated successfully, but these errors were encountered: