www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11455] New: Overriding template methods should raise a compile error

https://d.puremagic.com/issues/show_bug.cgi?id=11455

           Summary: Overriding template methods should raise a compile
                    error
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: david.eckardt sociomantic.com


--- Comment #0 from David Eckardt <david.eckardt sociomantic.com> 2013-11-06
08:37:53 PST ---
The "override" keyword can be applied to template methods but they don't
actually override. Consider the following example:

---
module tmpoverr;

class A
{
    int f(T)(T t) {return 47;}
}

class B : A
{
    override int f(T)(T t) {return 11;}
}

void main ( )
{
    A b = new B;
    assert(b.f(0) == 47); // passes: A.f() called, not B.f()
    assert(b.f(0) == 11); // fails for the same reason
}
---

It should be a compile error error to use the "override" keyword with a
template method.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 06 2013