diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index fb5ae01..22d0d29 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -267,9 +267,10 @@ class AutowiredRegistration(RegistrationType : Object) : Registration { void delegate() preDestructor = null; foreach (memberName; __traits(allMembers, RegistrationType)) { mixin(createImportsString!RegistrationType); + enum QualifiedName = fullyQualifiedName!RegistrationType ~ `.` ~ memberName; static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isFunction!(mixin(fullyQualifiedName!RegistrationType ~ `.` ~ memberName)) + && isFunction!(QualifiedName) && hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) { preDestructor = &__traits(getMember, instance, memberName); }