Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor with injected parameters not supported by newInstanceOf #28

Open
frabass opened this issue Sep 9, 2013 · 0 comments
Open

Comments

@frabass
Copy link

frabass commented Sep 9, 2013

I read the documentation, changelog and scaladoc this is taken from the changelog:

"Subcut 2.0 now will inject no-constructor-parameter classes and also classes that require only an implicit binding module. It can't reflectively inject other constructor parameters (because, how would you? :-) )"

I'm not a reflection expert, but is not clear if this is technically impossible or not:
Guice recursively injects constructor until gets to the point that knows how to build the injected object, can't subcut just do the same and look up the bindings its map?
Again, don't know about facilities offered by Scala reflection, but since Guice does this in Java I expect it to be feasible in Scala as well.

The reason why this would be useful is so that you can always use bindIfMissing and in test just build the object calling the constructor passing teststubs as parameters without bothering messing with fake bindings.

On the other hand would probably make more complex what in Guice is called assisted injection (having part of the parameters in the constructor injected and part passed) which in subcut comes for free while in Guice is kind of painful probably because of the fact that it needs to always know exactly how to inject the constructor.
https://code.google.com/p/google-guice/wiki/AssistedInject

Feel free to close this if it's either not feasible or too much work/out of scope, just wanted to understand if there's a technical block.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant