diff --git a/CHANGES.md b/CHANGES.md index 42359f6..7e74e5f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ Poodinis Changelog ================== + +**Version NEXT** +* FIX unnecessary re-registration of types when registerBeforeResolving is specified. + **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 2178dd6..c45d921 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -343,18 +343,19 @@ synchronized class DependencyContainer 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, 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, ResolveOption.noResolveException)) {