Skip to content

Commit

Permalink
fix issue 17791 - add __traits(deprecated, symbol)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkyp committed Oct 3, 2017
1 parent 5627785 commit 9e13139
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ddmd/id.d
Expand Up @@ -346,6 +346,7 @@ immutable Msgtable[] msgtable =
{ "isFinalClass" },
{ "isTemplate" },
{ "isPOD" },
{ "isDeprecated" },
{ "isNested" },
{ "isFloating" },
{ "isIntegral" },
Expand Down
5 changes: 5 additions & 0 deletions src/ddmd/traits.d
Expand Up @@ -66,6 +66,7 @@ shared static this()
"isAbstractClass",
"isArithmetic",
"isAssociativeArray",
"isDeprecated",
"isFinalClass",
"isPOD",
"isNested",
Expand Down Expand Up @@ -465,6 +466,10 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
{
return isTypeX(t => t.toBasetype().ty == Taarray);
}
if (e.ident == Id.isDeprecated)
{
return isDsymX(t => t.isDeprecated());
}
if (e.ident == Id.isStaticArray)
{
return isTypeX(t => t.toBasetype().ty == Tsarray);
Expand Down
20 changes: 20 additions & 0 deletions test/compilable/test17791.d
@@ -0,0 +1,20 @@
deprecated("A deprecated class") {
class DepClass
{
}
}

class NewClass
{
}

void main()
{
// test that a symbol (which is not likely to be deprecated)
// is not depercated
static assert(!__traits(isDeprecated, int));
// check that a class marked deprecated "isDeprecated"
static assert(__traits(isDeprecated, DepClass));
// check that a class not marked deprecated is not deprecated
static assert(!__traits(isDeprecated, NewClass));
}

0 comments on commit 9e13139

Please sign in to comment.