superMemberInjector generated with missing type information
See original GitHub issueIn Toothpick 3.0.0 there’s an issue where the generated __MemberInjector
has an incorrect superMemberInjector
field i.e. it does not set the type argument correctly.
E.g. assume we have AddNewActivity
with @Inject
annotated fields. AddNewActivity
extends BaseActivity
which has a type parameter e.g.
public class AddNewActivity extends BaseActivity<Integer> {
// ...
}
where BaseActivity
is:
abstract class BaseActivity<T> : SomeInterfaceWithGeneric<T>, AppCompatActivity() {
@Inject
lateinit var dummyDependency: DummyDependency
}
When you try to build the project KAPT will fail with the following reason:
> Task :kaptDebugKotlin FAILED
e: /Users/me/workspace/toothpick/toothpick-sample/build/generated/source/kapt/debug/com/example/toothpick/activity/AddNewActivity__MemberInjector.java:9: error: cannot find symbol
private MemberInjector<BaseActivity<T>> superMemberInjector = new com.example.toothpick.activity.BaseActivity__MemberInjector();
^
symbol: class T
location: class AddNewActivity__MemberInjector
e: /Users/me/workspace/toothpick/toothpick-sample/build/generated/source/kapt/debug/com/example/toothpick/activity/AdvancedBackpackItemsActivity__MemberInjector.java:9: error: cannot find symbol
private MemberInjector<BaseActivity<T>> superMemberInjector = new com.example.toothpick.activity.BaseActivity__MemberInjector();
Generated AddNewActivity__MemberInjector
public final class AddNewActivity__MemberInjector implements MemberInjector<AddNewActivity> {
private MemberInjector<BaseActivity<T>> superMemberInjector = new com.example.toothpick.activity.BaseActivity__MemberInjector();
@Override
public void inject(AddNewActivity target, Scope scope) {
superMemberInjector.inject(target, scope);
target.backpackItemValidator = scope.getInstance(BackpackItemValidator.class);
}
}
I’ve added an example in toothpick-sample
app to reproduce this:
https://github.com/stephanenicolas/toothpick/compare/master...zawadz88:super-member-injector-bug
This happens if AddNewActivity
is in either Java or Kotlin and has @Inject
annotated fields/properties. The issue does not occur in Kotlin when using the newly introduced inject delegates (thanks for introducing these!).
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (10 by maintainers)
Top GitHub Comments
Thanks! I’d probably add some info to check if all checks pass before submitting the PR (for forked repos the build gets executed once you submit a PR). So in other words execute the same commands which are specified in
.travis.yml
:What do you think?
Nice to start the week with a PR for TP! Reviewed.