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

Accessibility not respected by the interface resolution algorithm #1986

@MichalStrehovsky

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();
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions