Skip to content

Commit

Permalink
Merge pull request dlang#6541 from MartinNowak/fix17130
Browse files Browse the repository at this point in the history
fix Issue 17130 - [REG2.074] ambiguous implicit super call

cherry-picked-by: Martin Krejcirik <mk@krej.cz>
  • Loading branch information
MartinNowak authored and tramker committed Dec 15, 2017
1 parent 30c5f83 commit aa9e396
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 @@ -934,12 +934,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 aa9e396

Please sign in to comment.