Skip to content

UnexpectedException with ksp.useKSP2=true #2036

Open

Description

When enabling ksp.useKSP2=true in my gradle.properties ksp fails for a module in my project. When removing ksp.useKSP2=true, it works as expected.

> Task :navigation-android:kspReleaseKotlin FAILED
e: [ksp] dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException$UnexpectedException: 
  Validation trace:
    => element (OBJECT): handler.di.NavHandlersModule
    => element (METHOD): provideNavHandlers(java.util.Map<java.lang.Class<?>,handler.NavHandler<?>>)
    => element (PARAMETER): handlers
    => type (DECLARED parameter type): java.util.Map<java.lang.Class<?>,handler.NavHandler<?>>
    => type (DECLARED type argument): java.lang.Class<?>
NavHandlersModule.kt

@Module
@InstallIn(SingletonComponent::class)
object NavHandlersModule {
  @Provides
  @Singleton
  fun provideNavHandlers(
    handlers: @JvmSuppressWildcards Map<Class<*>, NavHandler<*>>
  ): NavHandlers {
    return NavHandlers(handlers)
  }
}
NavHandler.kt

abstract class NavHandler<B : NavBundle> {
  abstract fun handle(bundle: B, host: NavHost, additionalHandlerParams: AdditionalHandlerParams)
}

NavBundle.kt

abstract class NavBundle

data object PhotoBundle : NavBundle()

@Module
@InstallIn(SingletonComponent::class)
interface PhotoNavHandlerModule {
  @Binds
  @IntoMap
  @ClassKey(PhotoBundle::class)
  fun bindPhotoNavHandler(it: PhotoNavHandler): NavHandler<*>
}


ksp version: 2.0.10-1.0.24
kotlin version: 2.0.10

Please let me know if there is any more info I can provide!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions