From 925c3f4119892e867417e6695756eb2a0b0aaf4e Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Mon, 26 Dec 2016 16:16:18 +0100 Subject: [PATCH] Fix check on whether a member was a function Checks on some kinds of members, such as constants, would trip up with the isCallable trait. --- source/poodinis/autowire.d | 3 ++- source/poodinis/container.d | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 6f544e8..617677e 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -264,9 +264,10 @@ class AutowiredRegistration(RegistrationType : Object) : Registration { private void delegate() getPreDestructor(RegistrationType instance) { void delegate() preDestructor = null; foreach (memberName; __traits(allMembers, RegistrationType)) { + mixin(`import ` ~ moduleName!RegistrationType ~ `;`); static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isCallable!(__traits(getMember, instance, memberName)) + && isFunction!(mixin(fullyQualifiedName!RegistrationType ~ `.` ~ memberName)) && hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) { preDestructor = &__traits(getMember, instance, memberName); } diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 6eb4342..1892ed5 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -390,9 +390,10 @@ synchronized class DependencyContainer { private void callPostConstructors(Type)(Type instance) { foreach (memberName; __traits(allMembers, Type)) { + mixin(`import ` ~ moduleName!Type ~ `;`); static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isCallable!(__traits(getMember, instance, memberName)) + && isFunction!(mixin(fullyQualifiedName!Type ~ `.` ~ memberName)) && hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) { __traits(getMember, instance, memberName)(); }