Bug 11455 – Overriding template methods should raise a compile error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-06T08:37:53Z
Last change time
2023-07-17T09:53:51Z
Keywords
accepts-invalid, diagnostic, pull
Assigned to
No Owner
Creator
David Eckardt
Comments
Comment #0 by david.eckardt — 2013-11-06T08:37:53Z
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.
Comment #1 by b2.temp — 2019-03-02T14:08:18Z
*** Issue 19232 has been marked as a duplicate of this issue. ***
Comment #2 by dlang-bot — 2023-06-26T17:26:49Z
@ntrel created dlang/dmd pull request #15350 "Fix Issue 11455 - Overriding template methods should raise a compile …" fixing this issue:
- Fix Issue 11455 - Overriding template methods should raise a compile error
https://github.com/dlang/dmd/pull/15350
Comment #3 by dlang-bot — 2023-07-17T09:53:51Z
dlang/dmd pull request #15350 "Fix Issue 11455 - Overriding template methods should raise a compile …" was merged into master:
- dff2e4fc59ffead5427119dae5e7e597eb935d8d by Nick Treleaven:
Fix Issue 11455 - Overriding template methods should raise a compile error
https://github.com/dlang/dmd/pull/15350