diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 3d95fdc..2cddda3 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -370,14 +370,15 @@ 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(QualifiedName)) - && hasUDA!(__traits(getMember, instance, memberName), PreDestroy)) + foreach (overload; __traits(getOverloads, instance, memberName)) { - preDestructor = &__traits(getMember, instance, memberName); + static if (__traits(compiles, __traits(getProtection, overload)) + && __traits(getProtection, overload) == "public" + && isFunction!overload + && hasUDA!(overload, PreDestroy)) + { + preDestructor = &__traits(getMember, instance, memberName); + } } } diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 2e8a4b7..30d4c2c 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -471,14 +471,15 @@ synchronized class DependencyContainer { foreach (memberName; __traits(allMembers, Type)) { - mixin(createImportsString!Type); - enum QualifiedName = fullyQualifiedName!Type ~ `.` ~ memberName; - static if (__traits(compiles, __traits(getProtection, __traits(getMember, instance, memberName))) - && __traits(getProtection, __traits(getMember, instance, memberName)) == "public" - && isFunction!(mixin(QualifiedName)) - && hasUDA!(__traits(getMember, instance, memberName), PostConstruct)) + foreach (overload; __traits(getOverloads, instance, memberName)) { - __traits(getMember, instance, memberName)(); + static if (__traits(compiles, __traits(getProtection, overload)) + && __traits(getProtection, overload) == "public" + && isFunction!overload + && hasUDA!(overload, PostConstruct)) + { + __traits(getMember, instance, memberName)(); + } } } } diff --git a/test/poodinis/testclasses.d b/test/poodinis/testclasses.d index 55ce023..b9fbc50 100644 --- a/test/poodinis/testclasses.d +++ b/test/poodinis/testclasses.d @@ -804,4 +804,19 @@ version (unittest) { } + + class AutowiredMethod + { + @Autowire + public int lala() + { + return 42; + } + + @Autowire + public int lala(int valla) + { + return valla; + } + } }