Skip to content

Commit

Permalink
fix Issue 15141 - Object.factory allows the creation of derived abstr…
Browse files Browse the repository at this point in the history
…act classes

`ClassDeclaration.isAbstract()` should be used to emit `ClassFlags::isAbstract` so it's considering abstract member functions.
  • Loading branch information
9rnsr committed Oct 14, 2015
1 parent 13f4193 commit 72fa908
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/toobj.c
Expand Up @@ -412,7 +412,7 @@ void toObjFile(Dsymbol *ds, bool multiobj)
break;
}
}
if (cd->isabstract)
if (cd->isAbstract())
flags |= ClassFlags::isAbstract;
for (ClassDeclaration *pc = cd; pc; pc = pc->baseClass)
{
Expand Down
19 changes: 19 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7676,6 +7676,24 @@ template isCustomSerializable15126(T)

alias bug15126 = isCustomSerializable15126!Json15126;

/***************************************************/
// 15141

class A15141
{
abstract void method();
}

class B15141 : A15141 { }

void test15141()
{
auto a = Object.factory(__MODULE__ ~ ".A15141");
assert(a is null);
auto b = Object.factory(__MODULE__ ~ ".B15141");
assert(b is null); // OK <- oops
}

/***************************************************/

int main()
Expand Down Expand Up @@ -7989,6 +8007,7 @@ int main()
test13952();
test13985();
test14211();
test15141();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 72fa908

Please sign in to comment.