Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid compilation failure(NonExistentClass) by kapt #599

Closed
wants to merge 2 commits into from
Closed

Avoid compilation failure(NonExistentClass) by kapt #599

wants to merge 2 commits into from

Conversation

yoshidan
Copy link

Dagger-compiler cause CompletionFailure when trying to create "InjectionSite"

 com.sun.tools.javac.code.Symbol$CompletionFailure: error.NonExistentClass

I' d like to resolve this problem.


Kolin compiler generate stubs and before the annotation processor run.

ex)
here is original source code.

class AppStartActivity {
   @Inject
   override lateinit var activityPresenter: AppStartActivityPresenter
   
   lateinit var mBinding: ActivityAppStartBinding
}

here is stub code generated by kotlin compiler.
the type of databinding or other code that will be generated by apt is "error.NonExistentClass"

public class AppStartActivity {
   @field:javax.inject.Inject protected open lateinit var mPresenter:AppStartActivityPresenter
   public final lateinit var mBinding: error.NonExistentClass
  

here is compiled java code.

public class LoginActivity {
    private error.NonExistentClass mBinding
    private AppStartActivityPresenter mPresenter
    protected void setMPresenter(mPresenter:AppStartActivityPresenter)
    public void setMBinding(error.NonExistentClass)
    ...

After generating stubs kotlin annotation processing tools(kapt) run and.
but dagger-compiler cause CompletionFailure when trying to create "InjectionSite" for "setMBinding"

 com.sun.tools.javac.code.Symbol$CompletionFailure: error.NonExistentClass

because dagger-compiler try to create "InjectionSite" for all public method even if the method doesn't have "@Inject" annotation.

I think dagger-compiler doesn't need to create "InjectionSite" for the method that doesn't have "@Inject".

@ronshapiro
Copy link

I think this is a bug for kapt to deal with, not Dagger. Can someone with knowledge of Kotlin+kapt provide more insight?

Unfortunately, we don't have any infrastructure to test with kapt. It would be ideal to have tests to make sure we don't break this in the future.

@ronshapiro ronshapiro closed this Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants