Fix registerOnResolve not working for classes that have no default constructor

It might be that these want to make use of constructor injection instead
This commit is contained in:
Mike Bierlee 2022-10-27 02:26:44 +03:00
parent f7578d79a3
commit 5a66bdc26a
2 changed files with 4 additions and 4 deletions

View file

@ -3,6 +3,7 @@ Poodinis Changelog
**Version NEXT** **Version NEXT**
* FIX unnecessary re-registration of types when registerBeforeResolving is specified. * 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** **Version 8.1.2**
* FIX compilation error on importing template types that are not actually types. * FIX compilation error on importing template types that are not actually types.

View file

@ -184,7 +184,6 @@ synchronized class DependencyContainer
SuperType)(RegistrationOption options = RegistrationOption.none) SuperType)(RegistrationOption options = RegistrationOption.none)
if (!is(ConcreteType == struct)) if (!is(ConcreteType == struct))
{ {
TypeInfo registeredType = typeid(SuperType); TypeInfo registeredType = typeid(SuperType);
TypeInfo_Class concreteType = typeid(ConcreteType); TypeInfo_Class concreteType = typeid(ConcreteType);
@ -346,10 +345,10 @@ synchronized class DependencyContainer
auto candidates = resolveType in registrations; auto candidates = resolveType in registrations;
if (!candidates) if (!candidates)
{ {
if (hasOption(resolveOptions, persistentResolveOptions, static if (is(typeof(typeid(QualifierType)) == TypeInfo_Class) && !__traits(isAbstractClass, QualifierType))
ResolveOption.registerBeforeResolving))
{ {
static if (__traits(compiles, new QualifierType())) if (hasOption(resolveOptions, persistentResolveOptions, ResolveOption
.registerBeforeResolving))
{ {
register!(RegistrationType, QualifierType)(); register!(RegistrationType, QualifierType)();
return resolve!(RegistrationType, QualifierType)(resolveOptions); return resolve!(RegistrationType, QualifierType)(resolveOptions);