Skip to content

Conversation

hpohl
Copy link
Contributor

@hpohl hpohl commented Jul 4, 2013

TypeFunction *tf = new TypeFunction(NULL, NULL, 0, LINKd, 0);
tf->isnothrow = btf->isnothrow;
tf->purity = btf->purity;
tf->trust = btf->trust;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In D2, baseClass->ctor may be template, so (CtorDeclaration *)baseClass->ctor would be wrong result...

I think following code would be better:

if (FuncDeclaration *f = resolveFuncCall(loc, sc, baseClass->ctor, NULL, NULL, NULL, 1))
{
    Type *tf = new TypeFunction(NULL, NULL, 0, LINKd, f->storage_class);
    ...
  1. resolveFuncCall returns actually instantiated function even when baseClass->ctor is template.
  2. TypeFunction constructor sets its fields by using StorageClass stc parameter. In this case, you can just pass f->storage_class to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work only for @safe nothrow pure this(), but not for this() @safe nothrow pure since they are part of the TypeFunction then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. You are right.

9rnsr added a commit that referenced this pull request Jul 4, 2013
fix issue 10542 - implicitly generated class ctor doesn't inherit base class ctor attributes
@9rnsr 9rnsr merged commit 9af380a into dlang:master Jul 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants