Remove helpful compilation warning in favor of supporting more edge-cases out of the box

This commit is contained in:
Mike Bierlee 2021-07-03 18:38:21 +03:00
parent d7dc57ec99
commit 70b4c9e9dd
5 changed files with 29 additions and 11 deletions

View file

@ -1,5 +1,8 @@
Poodinis Changelog
==================
**Version 8.1.0-beta.7**
* REVERT fix for issue #31. It broke too many valid cases.
**Version 8.1.0-beta.6**
* FIX multiple template arguments not allowed on constructor argument injection (PR #37)

View file

@ -1,6 +1,6 @@
Poodinis Dependency Injection Framework
=======================================
Version 8.1.0-beta.6
Version 8.1.0-beta.7
Copyright 2014-2021 Mike Bierlee
Licensed under the terms of the MIT license - See [LICENSE.txt](LICENSE.txt)

View file

@ -218,16 +218,6 @@ synchronized class DependencyContainer
return newRegistration;
}
public Registration register(SuperType, ConcreteType)(
RegistrationOption options = RegistrationOption.none)
if (!is(SuperType == ConcreteType) && !is(BaseTypeTuple!ConcreteType == AliasSeq!(Object,
SuperType)) && !is(BaseTypeTuple!ConcreteType == AliasSeq!(SuperType)))
{
pragma(msg, "Cannot register dependency: ", ConcreteType,
" is not derived from ", SuperType);
static assert(0, "Cannot register dependency");
}
private bool hasOption(OptionType)(OptionType options,
OptionType persistentOptions, OptionType option)
{

View file

@ -673,4 +673,14 @@ version (unittest)
assert(instance.preDestroyWasCalled == true);
}
// Test register class by ancestor type
unittest
{
auto container = new shared DependencyContainer();
container.register!(Grandma, Kid);
auto instance = container.resolve!Grandma;
assert(instance !is null);
}
}

View file

@ -789,4 +789,19 @@ version (unittest)
this.dependency = assignedDependency;
}
}
class Grandma
{
}
class Mommy : Grandma
{
}
class Kid : Mommy
{
}
}