Skip to content

Multiple matches for the interface member warning is not reported static members #61553

@AlekseyTs

Description

@AlekseyTs

Consider the following code for instance method:

interface I1
{
    abstract void M(int x);
}

class Base<T>
{
    public void M(T x){}
    public void M(int x){}
}

class Derived : Base<int>, I1  // warning CS1956: Member 'Base<int>.M(int)' implements interface member 
                               // 'I1.M(int)' in type 'Derived'. There are multiple matches for the 
                               // interface member at run-time. It is implementation dependent
                               // which method will be called.
{
}

Observed: CS1956 warning reported for class Derived.

Now try the same scenario with a static method:

interface I1
{
    abstract static void M(int x);
}

class Base<T>
{
    public static void M(T x){}
    public static void M(int x){}
}

class Derived : Base<int>, I1
{
}

Observed: No CS1956 warning
Expected: CS1956 warning reported for class Derived.

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