Skip to content

Commit

Permalink
Merge pull request #6290 from Spoov/fix_getSymbolsByUDA
Browse files Browse the repository at this point in the history
Fix Issue 18624 - wrong behavior of getSymbolsByUDA if one of the symbols having th…
  • Loading branch information
wilzbach authored Mar 17, 2018
2 parents 42e8b19 + 9ab9b01 commit e5d92c1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -7877,7 +7877,8 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
else static if (isFunction!member)
{
enum hasSpecificUDA(alias member) = hasUDA!(member, attribute);
alias getSymbolsByUDAImpl = Filter!(hasSpecificUDA, __traits(getOverloads, symbol, names[0]));
alias overloadsWithUDA = Filter!(hasSpecificUDA, __traits(getOverloads, symbol, names[0]));
alias getSymbolsByUDAImpl = AliasSeq!(overloadsWithUDA, tail);
}
else static if (hasUDA!(member, attribute))
{
Expand Down Expand Up @@ -8020,6 +8021,21 @@ private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...)
static assert(res[0].stringof == "a");
}

// #18624: getSymbolsByUDA produces wrong result if one of the symbols having the UDA is a function
@safe unittest
{
enum Attr;
struct A
{
@Attr void a();
@Attr void a(int n);
void b();
@Attr void c();
}

static assert(getSymbolsByUDA!(A, Attr).stringof == "tuple(a, a, c)");
}

/**
Returns: $(D true) iff all types $(D T) are the same.
*/
Expand Down

0 comments on commit e5d92c1

Please sign in to comment.