Add conditional __compiles check before calling __traits(getOverloads, ...) in AutowiredRegistration.getPreDestructor.

This commit is contained in:
Vijay Nayar 2024-06-11 14:01:33 +02:00 committed by Mike Bierlee
parent 426b1774b8
commit 4f0510d2c9

View file

@ -309,12 +309,14 @@ class AutowiredRegistration(RegistrationType : Object) : Registration {
private void delegate() getPreDestructor(RegistrationType instance) { private void delegate() getPreDestructor(RegistrationType instance) {
void delegate() preDestructor = null; void delegate() preDestructor = null;
static foreach (memberName; __traits(allMembers, RegistrationType)) { static foreach (memberName; __traits(allMembers, RegistrationType)) {
static foreach (overload; __traits(getOverloads, RegistrationType, memberName)) { static if (__traits(compiles, __traits(getOverloads, RegistrationType, memberName))) {
static if (__traits(compiles, __traits(getProtection, overload)) static foreach (overload; __traits(getOverloads, RegistrationType, memberName)) {
&& __traits(getProtection, overload) == "public" static if (__traits(compiles, __traits(getProtection, overload))
&& isFunction!overload && __traits(getProtection, overload) == "public"
&& hasUDA!(overload, PreDestroy)) { && isFunction!overload
preDestructor = &__traits(getMember, instance, memberName); && hasUDA!(overload, PreDestroy)) {
preDestructor = &__traits(getMember, instance, memberName);
}
} }
} }
} }