[Issue 15010] New: Base interface member is shadowed inside the derived interface member body (template overloading issue)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 3 23:19:01 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15010

          Issue ID: 15010
           Summary: Base interface member is shadowed inside the derived
                    interface member body (template overloading issue)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: maximzms at gmail.com

DMD64 D Compiler v2.067.1

In the code below Parent.foo is somehow shadowed (but still accessible) inside
Child.foo body.
Note that Parent.foo is "imported" to Child by alias declaration and is
included in Child.foo overload set.
The same error occurs for both interfaces and classes. 

test.d:
----------------------------------------
interface Parent
{
    static void foo(T)() {}

    static void foo(T : dchar)()
    {
        foo!int(); // OK
    }
}

interface Child : Parent
{
    alias foo = Parent.foo;

    static void foo(T : char)()
    {
        Parent.foo!int(); // OK
        Child.foo!int(); // OK
        { alias foo = Parent.foo; foo!int(); } // OK
        { alias foo = Child.foo; foo!int(); } // OK
        foo!int(); // Error
    }
}

void main()
{
    Child.foo!char();
}
----------------------------------------

`dmd test` output:
----------------------------------------
test.d(21): Error: template instance foo!int does not match template
declaration foo(T : char)()
test.d(27): Error: template instance test.Child.foo!char error instantiating
----------------------------------------

--


More information about the Digitalmars-d-bugs mailing list