square / dagger

A fast dependency injector for Android and Java.

Home Page:https://square.github.io/dagger/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"InjectAdapter uses unchecked or unsafe operations" when injecting parameterized type into generic class

mattlogan opened this issue · comments

I'm seeing the following compiler warning with field injection of a parameterized type inside a generic class:

Note: <path to generated class>/Foo$$InjectAdapter.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

As a simple example, I'm using the following generic class:

public class Foo<T> {
    @Inject Bar<Baz> bazBar;
}

And the following module:

@Module(
           injects = Foo.class
)
public class MainModule {
    @Provides Bar<Baz> provideBazBar() {
        return new Bar<>();
    }
}

To verify, clone this sample project and run ./gradlew clean compileDebugJavaWithJavac