diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 22d0d29..80864aa 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -270,7 +270,7 @@ class AutowiredRegistration(RegistrationType : Object) : Registration { enum QualifiedName = fullyQualifiedName!RegistrationType ~ `.` ~ memberName; static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isFunction!(QualifiedName) + && isFunction1!(mixin(QualifiedName)) && hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) { preDestructor = &__traits(getMember, instance, memberName); } diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 5b0f759..47e8c95 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -443,7 +443,7 @@ synchronized class DependencyContainer { enum QualifiedName = fullyQualifiedName!Type ~ `.` ~ memberName; static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isFunction!(QualifiedName) + && isFunction1!(mixin(QualifiedName)) && hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) { __traits(getMember, instance, memberName)(); } diff --git a/source/poodinis/polyfill.d b/source/poodinis/polyfill.d index 0d6dc99..33d5d2a 100644 --- a/source/poodinis/polyfill.d +++ b/source/poodinis/polyfill.d @@ -43,21 +43,24 @@ static if (!__traits(compiles, basicExceptionCtors)) { } } -static if (!__traits(compiles, isFunction)) { - template isFunction(X...) if (X.length == 1) +static if (!__traits(compiles, isFunction1)) { + template isFunction1(X...) { + static if (X.length > 1) { + enum isFunction1 = false; + } else static if (is(typeof(&X[0]) U : U*) && is(U == function) || is(typeof(&X[0]) U == delegate)) { // x is a (nested) function symbol. - enum isFunction = true; + enum isFunction1 = true; } else static if (is(X[0] T)) { // x is a type. Take the type of it and examine. - enum isFunction = is(T == function); + enum isFunction1 = is(T == function); } else - enum isFunction = false; + enum isFunction1 = false; } }