Fix unnecessary re-registration of types when registerBeforeResolving is specified

This commit is contained in:
Mike Bierlee 2022-10-27 01:42:09 +03:00
parent e1cb511178
commit f7578d79a3
2 changed files with 11 additions and 6 deletions

View file

@ -1,5 +1,9 @@
Poodinis Changelog Poodinis Changelog
================== ==================
**Version NEXT**
* FIX unnecessary re-registration of types when registerBeforeResolving is specified.
**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

@ -343,18 +343,19 @@ synchronized class DependencyContainer
writeln("DEBUG: Resolving type " ~ resolveType.toString() ~ " with qualifier " ~ qualifierType.toString()); writeln("DEBUG: Resolving type " ~ resolveType.toString() ~ " with qualifier " ~ qualifierType.toString());
} }
static if (__traits(compiles, new QualifierType())) auto candidates = resolveType in registrations;
if (!candidates)
{ {
if (hasOption(resolveOptions, persistentResolveOptions, if (hasOption(resolveOptions, persistentResolveOptions,
ResolveOption.registerBeforeResolving)) ResolveOption.registerBeforeResolving))
{ {
register!(RegistrationType, QualifierType)(); static if (__traits(compiles, new QualifierType()))
{
register!(RegistrationType, QualifierType)();
return resolve!(RegistrationType, QualifierType)(resolveOptions);
}
} }
}
auto candidates = resolveType in registrations;
if (!candidates)
{
if (hasOption(resolveOptions, persistentResolveOptions, if (hasOption(resolveOptions, persistentResolveOptions,
ResolveOption.noResolveException)) ResolveOption.noResolveException))
{ {