diff --git a/CHANGES.md b/CHANGES.md index 480752e..5bc7e7a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/README.md b/README.md index 507e2a4..96717fd 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/source/poodinis/container.d b/source/poodinis/container.d index debbfba..fd549e7 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -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) { diff --git a/test/poodinis/containertest.d b/test/poodinis/containertest.d index 2ba1028..3c8f2df 100644 --- a/test/poodinis/containertest.d +++ b/test/poodinis/containertest.d @@ -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); + } } diff --git a/test/poodinis/testclasses.d b/test/poodinis/testclasses.d index 4e6133e..73ae5ad 100644 --- a/test/poodinis/testclasses.d +++ b/test/poodinis/testclasses.d @@ -789,4 +789,19 @@ version (unittest) this.dependency = assignedDependency; } } + + class Grandma + { + + } + + class Mommy : Grandma + { + + } + + class Kid : Mommy + { + + } }