Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Accessibility not respected by the interface resolution algorithm #1986

Closed
dotnet/runtime
#81409

Description

@MichalStrehovsky

B.f is protected and we shouldn't consider it as implementing the interface.

using System;
interface I
{
    int f();
}
class A
{
    public int f()
    {
        Console.WriteLine("Correct  ->  Should be in A.f()");
        return 100;
    }
}
class B : A, I
{
    new protected virtual int f()
    {
        Console.WriteLine("Incorrect  ->  Shouldnt be in B.f()");
        return 1;
    }
    static int Main()
    {
        B b = new B();
        I i = b;
        return i.f();
    }
}

Activity

  1. MichalStrehovsky commented on Oct 6, 2016

    @MichalStrehovsky
    MemberAuthor

    Cc @hoyMS

  2. added this to the milestone on Oct 20, 2016
  3. changed the title [-]Method declaration order not respected in interface method resolution[/-] [+]Accessibility not respected by the interface resolution algorithm[/+] on Jan 18, 2018
  4. added a commit that references this issue on Jan 31, 2023
    7d126c7
  5. added a commit that references this issue on Feb 2, 2023
    60fa29b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions