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

[Default Interfaces] Support constrained interface calls on value types #9490

Open
MichalStrehovsky opened this issue Jan 2, 2018 · 2 comments
Open
Milestone

Comments

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Jan 2, 2018

Pull request dotnet/coreclr#21978 made us throw in this situation, but the correct behavior would be to make a thunk that will box the this, and dispatch to the target default interface method.

@gafter

This comment has been minimized.

Copy link
Member

@gafter gafter commented Oct 25, 2019

The following code compiles and runs without throwing. Not sure what scenario is not handled properly.

using System;

class Program
{
    static void Main(string[] args)
    {
        S1 s = new S1();
        M(s);
    }

    static void M<T>(T t) where T : I1
    {
        t.M();
    }
}

interface I1
{
    void M() { Console.WriteLine("I1.M"); }
}

struct S1 : I1
{
}
@MichalStrehovsky

This comment has been minimized.

Copy link
Member Author

@MichalStrehovsky MichalStrehovsky commented Oct 25, 2019

It's specifically for the corner case mentioned in the pull request (there is an il test too).

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.