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 Interface Method Base Calls #32054

Closed
gafter opened this issue Dec 29, 2018 · 4 comments
Closed

Default Interface Method Base Calls #32054

gafter opened this issue Dec 29, 2018 · 4 comments
Assignees
Milestone

Comments

@gafter
Copy link
Member

gafter commented Dec 29, 2018

The LDM decided on the base invocation syntax base(N.I1<T>).M(s). We also decided that the syntax should be permitted in classes (e.g. to invoke an implementation from a skip-base class or a base interface).

This needs to be implemented in the compiler. Also, we need to decide on an implementation strategy. What IL would that generate? Since interface implementations are currently private methods, it may require further CLR changes.

@gafter
Copy link
Member Author

gafter commented Jan 28, 2019

According to my notes, for a base call like

base(Type).M();

where Type is an interface type,

  1. The invocation needs to be unambiguous - there needs to be a unique declaration of M that is binds to. That declaration would be in the type Type or some base interface of Type.
  2. The compiler also needs to check that Type has a unique most specific override for the method selected by overload resolution. In other words, the following must be an error
interface A
{
    void M();
}
interface B : A
{
    override A.M() {}
}
interface C : A
{
    override A.M() {}
}
interface D : B, C
{
}
interface E : D
{
    override A.M()
    {
        base(D).M(); // error due to A.M not having a most specific override in D
    }
}

The marked line satisfies condition (1) as A.M is the only method to call, but fails condition (2).

@AlekseyTs
Copy link
Contributor

LDM (2019-04-29) decided to remove the base(Type) syntax from the scope of C# 8.0. This issue is tracking the work to put it back into the product once we have support from CLR.

@AlekseyTs AlekseyTs reopened this May 2, 2019
AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue May 2, 2019
@gafter gafter modified the milestones: 16.1, Compiler.Next May 2, 2019
@gafter gafter removed their assignment Jul 4, 2020
@AlekseyTs AlekseyTs removed the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Dec 1, 2020
@AlekseyTs
Copy link
Contributor

Closing for now because we don't have concrete plan to add this feature in the next release.

@AndriySvyryd
Copy link
Member

Related: dotnet/csharplang#2337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants