Skip to content

VB DIM: Unexpected accessibility error while trying to access protected method declared in an interface #35827

@AlekseyTs

Description

@AlekseyTs
        <Fact>
        Public Sub MethodImplementation_13()

            Dim csSource =
"
public interface I1
{
    protected static void M1()
    {
        System.Console.WriteLine(""I1.M1"");
    }
}
"
            Dim csCompiation = GetCSharpCompiation(csSource).EmitToImageReference()

            Dim source1 =
<compilation>
    <file name="c.vb"><![CDATA[
Public Class C
    Implements I1
    Shared Sub Main()
        I1.M1()
    End Sub
End Class
]]></file>
</compilation>

            Dim comp1 = CreateCompilation(source1, options:=TestOptions.DebugExe, targetFramework:=TargetFramework.NetStandardLatest, references:={csCompiation})
            CompileAndVerify(comp1, expectedOutput:=If(ExecutionConditionUtil.IsMonoOrCoreClr, "I1.M1", Nothing), verify:=VerifyOnMonoOrCoreClr)
        End Sub

Observed:

c.vb(4) : error BC30390: 'I1.Sub M1()' is not accessible in this context because it is 'Protected'.

Consuming public static methods works

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions