Skip to content

Commit

Permalink
Changing factory to get the target scope only when needed. Solves #111
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemures committed Sep 22, 2016
1 parent 799abe9 commit 2adc86d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,8 @@

## Release version 1.0.0-RC10 (XXX 2016)

* Issue [#111](https://github.com/stephanenicolas/toothpick/issues/111) Adding support for the SuppressWarnings annotation to remove missing constructor warning.
* Solves issue [#110](https://github.com/stephanenicolas/toothpick/issues/110) Adding support for the SuppressWarnings annotation to remove missing constructor warning.
* Solves issue [#111](https://github.com/stephanenicolas/toothpick/issues/111) Changing factory to get the target scope only when needed.
* Solves issue [#150](https://github.com/stephanenicolas/toothpick/issues/150): bindings are now allowed when the target of the binding uses an annotation that is supported by the scope where the binding is installed.

## Release version 1.0.0-RC9 (Aug 26th 2016)
Expand Down
Expand Up @@ -79,7 +79,11 @@ private void emitCreateInstance(TypeSpec.Builder builder) {

//change the scope to target scope so that all dependencies are created in the target scope
//and the potential injection take place in the target scope too
createInstanceBuilder.addStatement("scope = getTargetScope(scope)");
if (!constructorInjectionTarget.parameters.isEmpty()
|| constructorInjectionTarget.superClassThatNeedsMemberInjection != null) {
// We only need it when the constructor contains parameters or dependencies
createInstanceBuilder.addStatement("scope = getTargetScope(scope)");
}

StringBuilder localVarStatement = new StringBuilder("");
String simpleClassName = getSimpleClassName(className);
Expand Down
Expand Up @@ -28,7 +28,6 @@ public void testEmptyConstructor() {
"public final class TestEmptyConstructor$$Factory implements Factory<TestEmptyConstructor> {", //
" @Override", //
" public TestEmptyConstructor createInstance(Scope scope) {", //
" scope = getTargetScope(scope);", //
" TestEmptyConstructor testEmptyConstructor = new TestEmptyConstructor();", //
" return testEmptyConstructor;", //
" }", //
Expand Down Expand Up @@ -127,7 +126,6 @@ public void test2Constructors_butOnlyOneIsInjected() {
"public final class Test2Constructors$$Factory implements Factory<Test2Constructors> {", //
" @Override", //
" public Test2Constructors createInstance(Scope scope) {", //
" scope = getTargetScope(scope);", //
" Test2Constructors test2Constructors = new Test2Constructors();", //
" return test2Constructors;", //
" }", //
Expand Down

0 comments on commit 2adc86d

Please sign in to comment.