Skip to content

Commit

Permalink
workaround for uniform constructor syntax to be introduced in D 2.066
Browse files Browse the repository at this point in the history
mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()")
will now even compile for scalar types
  • Loading branch information
linkrope committed Jul 30, 2014
1 parent 306acd4 commit d711ec6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dunit/framework.d
Expand Up @@ -692,10 +692,13 @@ mixin template UnitTest()

private template _memberFunctions(alias T, attribute, names...)
{
import std.traits;

static if (names.length == 0)
immutable(string[]) _memberFunctions = [];
else
static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()"))
static if (isSomeFunction!(mixin(T.stringof ~ '.' ~ names[0]))
&& __traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()"))
&& _hasAttribute!(T, names[0], attribute))
immutable(string[]) _memberFunctions = [names[0]] ~ _memberFunctions!(T, attribute, names[1 .. $]);
else
Expand All @@ -712,10 +715,13 @@ mixin template UnitTest()

private template _annotations(alias T, attribute, names...)
{
import std.traits;

static if (names.length == 0)
immutable(string[]) _annotations = [];
else
static if (__traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()")))
static if (isSomeFunction!(mixin(T.stringof ~ '.' ~ names[0]))
&& __traits(compiles, mixin("(new " ~ T.stringof ~ "())." ~ names[0] ~ "()")))
{
alias member = TypeTuple!(__traits(getMember, T, names[0]));
alias attributes = TypeTuple!(__traits(getAttributes, member));
Expand Down

0 comments on commit d711ec6

Please sign in to comment.