question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

superMemberInjector generated with missing type information

See original GitHub issue

In 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:closed
  • Created 4 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
zawadz88commented, Aug 27, 2019

I added a Contributing.md file to the repo. Feel free to review it.

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:

./gradlew clean check
./gradlew -b toothpick-sample/build.gradle clean check -x lint

What do you think?

1reaction
dlemurescommented, Aug 26, 2019

Nice to start the week with a PR for TP! Reviewed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relation Prediction via Graph Neural Network in ...
Relation Prediction via Graph Neural Network in Heterogeneous Information Networks with Missing Type Information. Authors: Han Zhang.
Read more >
com.squareup.javapoet.TypeName Java Examples
This page shows Java code examples of com.squareup.javapoet.TypeName.
Read more >
Java Examples for com.squareup.javapoet.FieldSpec
This java examples will help you to understand the usage of com.squareup.javapoet.FieldSpec. These source code samples are taken from different open source ...
Read more >
A scope tree based Dependency Injection (DI) library for Java ...
All dependencies created via Toothpick, and available for injections, ... superMemberInjector generated with missing type information.
Read more >
toothpick from stephanenicolas - GithubHelp
All dependencies created via Toothpick, and available for injections, ... Or do I need to create some kind of wrapper or factory class...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found