It's pointless to make a type parameter with a struct
constraint covariant. Generic variance isn't supported for value type type arguments at all - so for example, there's no conversion from IEnumerable<int>
to either IEnumerable<long>
or IEnumerable<object>
even though there are conversions from int
to both long
and object
.
The problem you're actually running into is that Nullable<T>
isn't covariant, but you're trying to use T
in a property of type Nullable<T>
. That's what's causing the error.
Personally I think it would be better if type parameters with struct
constraints couldn't be declared to be covariant or contravariant (given that it won't be useful) but that in itself isn't prohibited.