An instance is returned which is created according to the registration scope with which they are registered.
ResolveException when type is not registered.
Resolve dependencies registered by super type and concrete type:
class Cat : Animal { ... } class Dog : Animal { ... } container.register!(Animal, Cat); container.register!Dog; container.resolve!Animal; container.resolve!Dog;
You cannot resolve a dependency when it is registered by multiple super types:
class Cat : Animal { ... } class Dog : Animal { ... } container.register!(Animal, Cat); container.register!(Animal, Dog); container.resolve!Animal; // Error: multiple candidates for type "Animal" container.resolve!Dog; // Error: No type is registered by concrete type "Dog", only by super type "Animal"
You need to use the resolve method which allows you to specify a qualifier.
Resolve dependencies.
Dependencies can only resolved using this method if they are registered by concrete type or the only concrete type registered by super type.
Resolved dependencies are automatically autowired before being returned.