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

[KSP2] Generated provider code failure when providing internal types for android library modules #4493

Open
mcumings opened this issue Oct 29, 2024 · 0 comments

Comments

@mcumings
Copy link

mcumings commented Oct 29, 2024

Preconditions:

  • Using Dagger 2.52
  • Using KSP 2.0.21-1.0.26
  • Using the org.jetbrains.kotlin.android and com.android.library gradle plugins (this works with standard kotlin + org.jetbrains.kotlin.jvm)

Provided an internal type:

internal class InternalType(val value: String)

A class which leverages the internal type:

internal class InjectionReceiver @Inject constructor(val internalType: InternalType)

and a module which defines a provider for it:

@Module
object ReproModule {
    @Provides
    internal fun provideInternalType(): InternalType = InternalType("Hello, World!")
}

The result of this is a compilation failure due to the generated factory code:

ReproModule_ProvideInternalType$libFactory.java:36: error: cannot find symbol
    return Preconditions.checkNotNullFromProvides(ReproModule.INSTANCE.provideInternalType$lib());
                                                                      ^
  symbol:   method provideInternalType$lib()
  location: variable INSTANCE of type ReproModule

The actual generated code at the point where it fails looks like this:

  public static InternalType provideInternalType$lib() {
    return Preconditions.checkNotNullFromProvides(ReproModule.INSTANCE.provideInternalType$lib());
  }

Looking at the generated code, it appears as if the above should read as follows:

  public static InternalType provideInternalType$lib() {
    return Preconditions.checkNotNullFromProvides(ReproModule.INSTANCE.provideInternalType$lib_debug());
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant