[scaldi-0.5.6] binding definition order relevant when injecting inheriting classes

19 views
Skip to first unread message

Ole Langbehn

unread,
Jul 8, 2015, 6:32:52 PM7/8/15
to sca...@googlegroups.com
Hi,

I found a bug in our code that's using scaldi. Take some classes in an inheritance chain A >: B >: C. I want to be able to inject any of them specifically. I can only do that when defining the bindings in reverse order (from subclass to superclass). In forward order I always get C.

It makes sense to me. Since scaldi explicitly defines that the last binding definition wins over previous ones, only the reverse definition can distinguish between the types, since a TypeTag check is only evaluated using isAssignableFrom. I still am not content with having to keep an eye on the definition order of bindings.

Maybe this could be documented?

I'm attaching a small test project for easy reproduction of the effect.
scaldi-bindingorder.tgz

Oleg Ilyenko

unread,
Jul 9, 2015, 1:59:43 PM7/9/15
to Ole Langbehn, sca...@googlegroups.com
Hi Ole,

Thanks a lot for pointing this out! I created a documentation issuue for this:


I will expand a bit on the binding order in context of class hierarchies in the documentation.  I will also think about how this can be improved in order to prevent bugs like this. This was an explicit desicion from the beginning to define binding overloading in this way. It,of course, opens a door for hard-to-spot issues like this. 

Cheers,
Oleg
--
You received this message because you are subscribed to the Google Groups "scaldi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scaldi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages