Open fanyang-mono opened 6 months ago
cc/ @lambdageek
We need to be careful in two ways:
interface I<T> where T : I<T>
scenarios)INumber<T>
, IBinaryNumber and friends on the basic integer types)My feeling is that checking the constraints in mono_class_init_internal
(the same as for generic instance parent/child classes) is going to be a bit too eager. Maybe we can push it off until a vtable is needed for some class and then check all the interfaces that it implements.
Moving to future and we should revisit if C# expands usage of ref structs.
Mono doesn't complain for these two cases. One idea to make it work is to inflate the parent interfaces with the concrete type and validate the parent interface generic parameters via
is_valid_generic_instantiation
, like class inheritance does inmono_class_init_internal
. Another idea is that maybe somewhere down the line frommono_class_implements_interface
is a good place to add this check and callmono_class_implements_interface
during class creation for classes which implements interfaces.