Skip to content

Commit

Permalink
Merge pull request #4589 from 9rnsr/fix13920
Browse files Browse the repository at this point in the history
Issue 13920 - DMD crash when trying to set a delegate from __traits(getOverloads)
  • Loading branch information
WalterBright committed Apr 17, 2015
2 parents 7400aa4 + c8173f3 commit bb7947b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/expression.c
Expand Up @@ -8059,9 +8059,10 @@ Expression *DelegateExp::semantic(Scope *sc)
e1 = e1->semantic(sc);
type = new TypeDelegate(func->type);
type = type->semantic(loc, sc);
AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration();
if (func->needThis())
e1 = getRightThis(loc, sc, ad, e1, func);
FuncDeclaration *f = func->toAliasFunc();
AggregateDeclaration *ad = f->toParent()->isAggregateDeclaration();
if (f->needThis())
e1 = getRightThis(loc, sc, ad, e1, f);
if (ad && ad->isClassDeclaration() && ad->type != e1->type)
{
// A downcast is required for interfaces, see Bugzilla 3706
Expand Down
25 changes: 25 additions & 0 deletions test/compilable/ice13920.d
@@ -0,0 +1,25 @@
// REQUIRED_ARGS: -o-
// PERMUTE_ARGS:

class Foo
{
void foo()
{
foreach (f; __traits(getOverloads, typeof(this), "bar"))
{
auto dg = &f;
}

foreach (f; __traits(getVirtualMethods, typeof(this), "bar"))
{
auto dg = &f;
}

foreach (f; __traits(getVirtualFunctions, typeof(this), "bar"))
{
auto dg = &f;
}
}

uint bar() { return 0; }
}

0 comments on commit bb7947b

Please sign in to comment.