Bug 13278 – Symbol undefined on reference to abstract method

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-10T19:46:00Z
Last change time
2014-08-11T13:50:14Z
Assigned to
nobody
Creator
blah38621

Comments

Comment #0 by blah38621 — 2014-08-10T19:46:44Z
Currently the following code will cause the linker to complain about not being able to find Visitor.visit(Object). module main; abstract class Visitor { abstract void visit(Object o); } final class SomeVisitor : Visitor { override void visit(Object o) { super.visit(o); } } void main() { } I believe that this should either be caught as an error by the compiler, or else, preferably, the compiler should simply not generate a call to the body of the base abstract method. The reason I believe that this should function that way is so that SomeVisitor.visit is not dependent on the exact implementation of Visitor. If you wanted to add some type of profiling or debugging output in the base class, and you weren't allowed to call super.visit on an abstract method without a body, then you'd have to go through each and every visitor and add the super.visit call, and then remove it again once you want to remove that profiling or debugging output. That would not be practical in any sense, thus my view of it.
Comment #1 by yebblies — 2014-08-11T13:41:44Z
*** This issue has been marked as a duplicate of issue 3396 ***
Comment #2 by yebblies — 2014-08-11T13:50:14Z
(In reply to Orvid King from comment #0) > The reason I believe that this should function that way is so that ... I suggest you do this by giving the base class function an empty body.