D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3206 - Class used as its member function parameter's default value is considered implementating only lexically preceeding abstract functions
Summary: Class used as its member function parameter's default value is considered imp...
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2009-07-24 00:39 UTC by Max Samukha
Modified: 2020-03-21 03:56 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2009-07-24 00:39:45 UTC
abstract class A
{
    abstract void foo();
}

class B : A
{
    void bar(B b = new B)
    {
    }

    void foo()
    {
    }
}

void main()
{
    auto a = new B;
}
----
test.d(19): Error: cannot create instance of abstract class B
test.d(19): Error: function foo is abstract

The bug can be worked around by placing 'foo' before 'bar':

class B : A
{
    void foo()
    {
    }

    void bar(B b = new B)
    {
    }
}
Comment 1 Denis Shelomovskii 2014-07-18 10:08:59 UTC
---
class B { abstract void f(); }

class C: B
{
    void g(C c = new C) { } // put after `f` to detrigger the issue
    override void f() { }
}
---

Note `interface` implementations are not affected.