This is a "feature" (albeit, not the best one) of AssistedInject -- the
@Inject constructors don't need to consume all the assisted param. This
helps when you want to bind the implementation to a stub that does less.

If you want the error checking, I believe you can annotate the cxtor
@AssistedInject instead of @Inject, and it will be a bit stricter.

sam

On Tue, Dec 15, 2015, 3:15 AM Geoff Groos <[email protected]>
wrote:

> Hey guys,
>
> I was allowed to execute this code without a provision error:
>
> public interface Factory {
>     PowershellFileWriter create(@Assisted Queryable<VariableSymbol>
> variables,
>                                 @Assisted @NotModified ToolTemplate
> toolTemplate,
>                                 @Assisted Path outputPath);
>
> }
> @Inject
> public PowershellFileWriter(FileSystem fileSystem,
>                             ResourceEnvironment.Factory envFactory,
>                             @Assisted Queryable<VariableSymbol> variables,
>                             @Assisted Path scriptPath,
>                             @Assisted Path outputPath) {
>
>     //...
> }
>
> when it is pretty clearly in error:
> - no use of ToolTemplate in the constructor
> - 2 assisted args of the same type without naming either
>
> The corrected version looks like this:
>
>     public interface Factory {
>         PowershellFileWriter create(Queryable<VariableSymbol> variables,
>                                     @Assisted("script") Path scriptPath,
>                                     @Assisted("out") Path outputPath);
>
>     }
>     @Inject
>     public PowershellFileWriter(FileSystem fileSystem,
>                                 ResourceEnvironment.Factory envFactory,
>                                 @Assisted Queryable<VariableSymbol>
> variables,
>                                 @Assisted("script") Path scriptPath,
>                                 @Assisted("out") Path outputPath) {
>
> why wasn't I given a resolution exception when I went to use this factory,
> or a configuration exception when I bound up this factory? Isn't validation
> done on the Factory interface when we use the FactoryModuleBuilder?
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/google-guice.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-guice/52237a42-109d-41e9-abb4-545dbbfc577a%40googlegroups.com
> <https://groups.google.com/d/msgid/google-guice/52237a42-109d-41e9-abb4-545dbbfc577a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/CAJEBNUeg7SCT5cMHMXNzc_Pcq-Yw__a-SdB0tSaS09ijUE2qrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to