Skip to content
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

[Mono] Enable support for IsByRefLike types in generics #94415

Closed
5 tasks done
Tracked by #65112
lambdageek opened this issue Nov 6, 2023 · 3 comments
Closed
5 tasks done
Tracked by #65112

[Mono] Enable support for IsByRefLike types in generics #94415

lambdageek opened this issue Nov 6, 2023 · 3 comments
Assignees
Labels
area-VM-meta-mono User Story A single user-facing feature. Can be grouped under an epic.
Milestone

Comments

@lambdageek
Copy link
Member

lambdageek commented Nov 6, 2023

Contributes to #65112

The 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

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 6, 2023
@lambdageek lambdageek added this to the 9.0.0 milestone Nov 6, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Nov 6, 2023
@lambdageek lambdageek added untriaged New issue has not been triaged by the area owner area-VM-meta-mono and removed area-Codegen-meta-mono untriaged New issue has not been triaged by the area owner labels Nov 6, 2023
@lambdageek
Copy link
Member Author

/cc @SamMonoRT

@lambdageek
Copy link
Member Author

lambdageek commented Jan 24, 2024

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.

interface I {
   void M();
}
ref struct RS : I {
   public void M () { ... }
}

static class C {
   public static void BadClient (I i) {
      i.M(); // ok, it's an interface method call
   }
   public static void GoodClient<T> (T t) where T : allow ref struct, 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
   }
}

RS s;
// 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.

@steveisok
Copy link
Member

Removed #99820 from the list since it can be done separately / not at all.

@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-VM-meta-mono User Story A single user-facing feature. Can be grouped under an epic.
Projects
None yet
Development

No branches or pull requests

3 participants