Skip to content

Commit

Permalink
Merge pull request #6541 from MartinNowak/fix17130
Browse files Browse the repository at this point in the history
fix Issue 17130 - ambiguous implicit super call
  • Loading branch information
MartinNowak committed Feb 15, 2017
2 parents 8f23808 + cfeb41a commit 69182da
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/dclass.d
Expand Up @@ -922,12 +922,15 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
// this() { }
if (!ctor && baseClass && baseClass.ctor)
{
auto fd = resolveFuncCall(loc, sc2, baseClass.ctor, null, null, null, 1);
auto fd = resolveFuncCall(loc, sc2, baseClass.ctor, null, type, null, 1);
if (!fd) // try shared base ctor instead
fd = resolveFuncCall(loc, sc2, baseClass.ctor, null, type.sharedOf, null, 1);
if (fd && !fd.errors)
{
//printf("Creating default this(){} for class %s\n", toChars());
auto btf = cast(TypeFunction)fd.type;
auto tf = new TypeFunction(null, null, 0, LINKd, fd.storage_class);
tf.mod = btf.mod;
tf.purity = btf.purity;
tf.isnothrow = btf.isnothrow;
tf.isnogc = btf.isnogc;
Expand Down
24 changes: 23 additions & 1 deletion test/compilable/test17130.d
Expand Up @@ -7,10 +7,32 @@ class Base
{}
}

class Derived : Base
class Derived1 : Base
{
this()
{
// implicit super();
}
}

class Derived2 : Base
{
// implicit this()
}

class Base2
{
this() shared
{}
}

class Derived3 : Base2
{
// implicit this() shared
}

void test()
{
auto d2 = new Derived2;
auto d3 = new shared(Derived3);
}

0 comments on commit 69182da

Please sign in to comment.