You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
generic sharing support: As a first cut we should probably just always create specific instance code for byreflike instances. On the other hand, the gpAcceptByRefLike param may allow gsharedvt to do a better job (since we know we would never need to box values of the type). Done in [mono] Add basic ref struct support for generic parameter #99081
We're gonna have a problem is mono_class_is_assignable_from_internal - we will need to make sure that we don't allow casting a ref struct RS to an interface I that it implements. The only way that kind of thing is allowed is if a generic param that allows ref structs is instantiated with a ref struct and then the method casts the generic param to the interface.
interfaceI{voidM();}refstructRS:I{publicvoidM(){ ...}}staticclassC{publicstaticvoidBadClient(Ii){i.M();// ok, it's an interface method call}publicstaticvoidGoodClient<T>(Tt)whereT:allowrefstruct,I{t.M();// also ok, constrained.callvirt - an interface method call through a gparam// both of these are not ok. it's a "box !!0 ; callvirt"// I i = (I)t;// i.M(); // illegal// - or -// ((I)t).M(); // illegal}}RSs;// I i1 = (I)s; // illegal - "box"// C.BadClient (s); // illegal - also "box"C.GoodClient<RS>(s);// okay, it's a call to a generic method instantiation.
Contributes to #65112
gpAcceptByRefLike
param may allow gsharedvt to do a better job (since we know we would never need to box values of the type). Done in [mono] Add basic ref struct support for generic parameter #99081The runtime design is specced out here: https://github.com/dotnet/runtime/blob/main/docs/design/features/byreflike-generics.md
There are tests in https://github.com/dotnet/runtime/tree/main/src/tests/Loader/classloader/generics/ByRefLike
The text was updated successfully, but these errors were encountered: