From b06fe4b8e98f903a6153620c217284cf7f7b9e8e Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 23 May 2013 07:48:43 +0900 Subject: [PATCH 1/2] Fix std.datetime (remove ReturnType usage for property check) --- std/datetime.d | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/std/datetime.d b/std/datetime.d index 9d7dd996a4f..57af05e2bf5 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -25824,9 +25824,7 @@ static TP delegate(in TP) everyDayOfWeek(TP, Direction dir = Direction.fwd)(DayO (dir == Direction.fwd || dir == Direction.bwd) && __traits(hasMember, TP, "dayOfWeek") && !__traits(isStaticFunction, TP.dayOfWeek) && - is(ReturnType!(TP.dayOfWeek) == DayOfWeek) && - (functionAttributes!(TP.dayOfWeek) & FunctionAttribute.property) && - (functionAttributes!(TP.dayOfWeek) & FunctionAttribute.nothrow_)) + is(typeof(TP.dayOfWeek) == DayOfWeek)) { TP func(in TP tp) { @@ -25958,9 +25956,7 @@ static TP delegate(in TP) everyMonth(TP, Direction dir = Direction.fwd)(int mont (dir == Direction.fwd || dir == Direction.bwd) && __traits(hasMember, TP, "month") && !__traits(isStaticFunction, TP.month) && - is(ReturnType!(TP.month) == Month) && - (functionAttributes!(TP.month) & FunctionAttribute.property) && - (functionAttributes!(TP.month) & FunctionAttribute.nothrow_)) + is(typeof(TP.month) == Month)) { enforceValid!"months"(month); @@ -33028,10 +33024,7 @@ template hasMin(T) { enum hasMin = __traits(hasMember, T, "min") && __traits(isStaticFunction, T.min) && - is(ReturnType!(T.min) == Unqual!T) && - (functionAttributes!(T.min) & FunctionAttribute.property) && - (functionAttributes!(T.min) & FunctionAttribute.nothrow_); - //(functionAttributes!(T.min) & FunctionAttribute.pure_); //Ideally this would be the case, but SysTime's min() can't currently be pure. + is(typeof(T.min) == Unqual!T); } unittest @@ -33061,10 +33054,7 @@ template hasMax(T) { enum hasMax = __traits(hasMember, T, "max") && __traits(isStaticFunction, T.max) && - is(ReturnType!(T.max) == Unqual!T) && - (functionAttributes!(T.max) & FunctionAttribute.property) && - (functionAttributes!(T.max) & FunctionAttribute.nothrow_); - //(functionAttributes!(T.max) & FunctionAttribute.pure_); //Ideally this would be the case, but SysTime's max() can't currently be pure. + is(typeof(T.max) == Unqual!T); } unittest From f52b88c5493d778ab2ecec4f7c2c20a714a3c563 Mon Sep 17 00:00:00 2001 From: k-hara Date: Sun, 2 Jun 2013 23:42:16 +0900 Subject: [PATCH 2/2] Fix internal template GetOverloadedMethods - should see overload first --- std/typecons.d | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/std/typecons.d b/std/typecons.d index 9d7b7897bce..7b79d5f32a6 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2974,21 +2974,24 @@ private template GetOverloadedMethods(T) { alias follows = TypeTuple!(); } + else static if (allMembers[i] == "this") + { + alias follows = follows!(i + 1); + } else { enum name = allMembers[i]; - template isFunction(T, string name) + template isMethod(alias f) { - static if (is(typeof(mixin("&T."~name)) F == F*) && is(F == function)) - enum isFunction = true; + static if (is(typeof(&f) F == F*) && is(F == function)) + enum isMethod = !__traits(isStaticFunction, f); else - enum isFunction = false; + enum isMethod = false; } - static if (isFunction!(T, name) && !__traits(isStaticFunction, mixin("T."~name))) - alias follows = TypeTuple!(__traits(getOverloads, T, name), follows!(i + 1)); - else - alias follows = follows!(i + 1); + alias follows = TypeTuple!( + std.typetuple.Filter!(isMethod, __traits(getOverloads, T, name)), + follows!(i + 1)); } } alias GetOverloadedMethods = follows!();