Skip to content
This repository was archived by the owner on Aug 24, 2022. It is now read-only.
This repository was archived by the owner on Aug 24, 2022. It is now read-only.

Incorrect method overload selection for interface method #892

Description

@iskiselev

If interface has overload generic/non-generic method incorrect method is selected. Test Case:

using System;

public static class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("**Interface**");
        var iObj = GetInterfaceHolder();
        iObj.Method(GetBase());
        iObj.Method(GetDerived());
        iObj.Method(GetInterface());
        iObj.Method<object>(GetBase());
        iObj.Method<object>(GetDerived());
    }

    public static Base GetBase()
    {
        return new Derived();
    }

    public static Derived GetDerived()
    {
        return new Derived();
    }

    public static IInterface GetInterface()
    {
        return new Derived();
    }

    public static IMethodHolder GetInterfaceHolder()
    {
        return new MethodHolder();
    }
}


public class Base : IInterface
{
}

public class Derived : Base
{
}

public interface IInterface
{
}

public interface IMethodHolder
{
    void Method(Base input);
    void Method(IInterface input);
    void Method(Derived input);
    void Method<T>(Derived input);
    void Method<T>(Base input);
}

public class MethodHolder : IMethodHolder
{
    public void Method(Base input)
    {
        Console.WriteLine("Base");
    }

    public void Method(IInterface input)
    {
        Console.WriteLine("IInterface");
    }

    public void Method(Derived input)
    {
        Console.WriteLine("Derived");
    }

    public void Method<T>(Derived input)
    {
        Console.WriteLine("GenericDerived");
    }

    public void Method<T>(Base input)
    {
        Console.WriteLine("GenericBase");
    }
}

Output:

// C# output begins //
**Interface**
Base
Derived
IInterface
GenericBase
GenericDerived
// JavaScript output begins //
**Interface**
Base
GenericDerived
IInterface
Base
GenericDerived

Translated source looks correct, so there is problem in JS implementation of signature selection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions