diff --git a/CHANGES.md b/CHANGES.md index 7e74e5f..e2a4d52 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ Poodinis Changelog **Version NEXT** * FIX unnecessary re-registration of types when registerBeforeResolving is specified. +* FIX registerOnResolve not working for classes that have no default constructor **Version 8.1.2** * FIX compilation error on importing template types that are not actually types. diff --git a/source/poodinis/container.d b/source/poodinis/container.d index c45d921..ed16a2f 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -184,7 +184,6 @@ synchronized class DependencyContainer SuperType)(RegistrationOption options = RegistrationOption.none) if (!is(ConcreteType == struct)) { - TypeInfo registeredType = typeid(SuperType); TypeInfo_Class concreteType = typeid(ConcreteType); @@ -346,10 +345,10 @@ synchronized class DependencyContainer auto candidates = resolveType in registrations; if (!candidates) { - if (hasOption(resolveOptions, persistentResolveOptions, - ResolveOption.registerBeforeResolving)) + static if (is(typeof(typeid(QualifierType)) == TypeInfo_Class) && !__traits(isAbstractClass, QualifierType)) { - static if (__traits(compiles, new QualifierType())) + if (hasOption(resolveOptions, persistentResolveOptions, ResolveOption + .registerBeforeResolving)) { register!(RegistrationType, QualifierType)(); return resolve!(RegistrationType, QualifierType)(resolveOptions);