Skip to content

VB DIM: Class cannot implement a virtual interface method #35821

@AlekseyTs

Description

@AlekseyTs
        <Fact>
        Public Sub MethodImplementation_02()

            Dim csSource =
"
public interface I1
{
    void M1() 
    {
    }
}
"
            Dim csCompiation = GetCSharpCompiation(csSource).EmitToImageReference()

            Dim source1 =
<compilation>
    <file name="c.vb"><![CDATA[
Public Class C
    Implements I1

    Sub M1() Implements I1.M1
        System.Console.WriteLine("C.M1")
    End Sub

    Shared Sub Main()
        Dim i1 As I1 = new C()
        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, "C.M1", Nothing), verify:=VerifyOnMonoOrCoreClr)
        End Sub

Observed:

c.vb(4) : error BC30401: 'M1' cannot implement 'M1' because there is no matching sub on interface 'I1'.

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