File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ To use, add the following dependency:
4444 - [ Specifying implementations to use] ( #specifying-implementations-to-use )
4545 - [ Using dependencies contained in objects] ( #using-dependencies-contained-in-objects )
4646 - [ Errors] ( #errors )
47+ - [ Limitiations of autowire] ( #limitiations-of-autowire )
4748- [ wire] ( #wire )
4849 - [How wiring works](#how-wiring-works)
4950 - [Factories](#factories)
@@ -212,6 +213,16 @@ autowire[UserStatusReader]()
212213// wiring path: UserStatusReader -> UserFinder -> DatabaseAccess
213214```
214215
216+ ## Limitiations of autowire
217+
218+ ` autowire ` doesn't handle propagating generic type parameters, when creating missing dependencies using constructors or
219+ ` apply ` methods. E.g. if you have a ` class B[X](a: A[X]) ` , and a ` B[Int] ` needs to be created, the specific value for
220+ the type parameter ` X ` won't be propagated when resolving the dependencies.
221+
222+ As a work-around, you need to explicitly provide the generic dependencies with concrete type parameters. A generic
223+ dependency might appear multiple times, with different type parameters. To wire the classes from the example, you'd
224+ need: ` autowire[...](B[Int](_), someInstance: A[Int]) ` or similar.
225+
215226# wire
216227
217228![ Scala 2] ( https://img.shields.io/badge/Scala%202-8A2BE2 )
You can’t perform that action at this time.
0 commit comments