diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 7b3c728..cfc2708 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -265,7 +265,8 @@ class AutowiredRegistration(RegistrationType : Object) : Registration { private void delegate() getPreDestructor(RegistrationType instance) { void delegate() preDestructor = null; foreach (memberName; __traits(allMembers, RegistrationType)) { - static if (__traits(getProtection, __traits(getMember, instance, memberName)) == "public" + static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) + && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" && isCallable!(__traits(getMember, instance, 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 ab08e52..3b85e9c 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -391,7 +391,8 @@ synchronized class DependencyContainer { private void callPostConstructors(Type)(Type instance) { foreach (memberName; __traits(allMembers, Type)) { - static if (__traits(getProtection, __traits(getMember, instance, memberName)) == "public" + static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) + && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" && isCallable!(__traits(getMember, instance, memberName)) && hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) { __traits(getMember, instance, memberName)();