www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18976] New: Inconsistency in overload merging with aliases

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

          Issue ID: 18976
           Summary: Inconsistency in overload merging with aliases
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

Consider the following code:
```
class Expression : Statement {}
class Statement {}

class AssertSemanticVisitor
{
    void visit (const Statement node)
    {
        assert(0, typeof(node).stringof);
    }
}

class ExpressionVisitor : AssertSemanticVisitor
{
    public void visit (Expression) { assert(0); }

    version (Deprecated)
        alias visit = super.visit;
    else version (FullType)
        alias visit = AssertSemanticVisitor.visit;
    else
        alias visit = typeof(super).visit;
}

void main ()
{
    scope x = new ExpressionVisitor;
    scope y = new Statement;
    x.visit(y);
}
```

All three `alias` should have the same effect, bar for the deprecation newly
implemented for the `Deprecated` version.

However, the first 2 versions perform as expected, however the `else` clause
leads to:
```
test.d(21): Error: alias `test.ExpressionVisitor.visit` conflicts with function
test.ExpressionVisitor.visit at test.d(14)
``

Marking it as major, as it makes the deprecation somewhat annoying.

--
Jun 12 2018