This problem appears only if one of the parameters is an interface. Without it or using any other type as a second parameter instead of the interface, it compiles. Also it compiles if the passed interface is null. The example below uses short/ushort, but I found the same behaviour for any combination of integral types of the same bitsize (byte/ubyte/char, ushort/short/wchar, int/uint/dchar, long/ulong)

D 2.066.1

interface I {}
class C: I {}

void func(ushort s, I i)
{
    writeln("ushort overload");
}

void func(short s, I i)
{
    writeln("short overload");
}

void call(short s)
{
    C c = new C();
    I d = new C();
    func(s, c); // ---- ERROR ---- see below

    //but these are ok

    func(s, cast(I)c) //ok
    func(s, d) //ok
    func(s, null) //ok

}

main.func called with argument types (short, C) matches both:   
main.func(short s, I i) 
main.func(ushort s, I i)        

Reply via email to