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

"KSTypeArgument.type should not have been null, please file a bug. STAR null" with KSP2.0.0-1.0.22 and KSP2 #1957

Open
lwasyl opened this issue Jun 6, 2024 · 2 comments

Comments

@lwasyl
Copy link

lwasyl commented Jun 6, 2024

 java.lang.IllegalStateException: KSTypeArgument.type should not have been null, please file a bug. STAR null
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeExtKt.requireType(KSTypeExt.kt:128)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspTypeArgumentType.<init>(KspTypeArgumentType.kt:41)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspTypeArgumentType.<init>(KspTypeArgumentType.kt:33)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspProcessingEnv.wrap(KspProcessingEnv.kt:280)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeArguments$2.invoke(KspType.kt:202)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeArguments$2.invoke(KspType.kt:198)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.getTypeArguments(KspType.kt:198)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateType(DaggerSuperficialValidation.java:337)
        ... 53 more

This happens when processing this file:

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import javax.inject.Inject
import javax.inject.Provider

class ViewModelFactory @Inject constructor(
    private val creators: Map<Class<*>, @JvmSuppressWildcards Provider<ViewModel>>,
) : ViewModelProvider.Factory {

    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T = creators[modelClass]?.get() as T
}

Kotlin 2.0.0 + KSP2.0.0-1.0.22 (ksp.useKSP2=true) + Dagger 2.51.1.

@neetopia
Copy link
Contributor

neetopia commented Jun 6, 2024

It looks an expected behavior to me, STAR projection should not have a type since it is literally a * at the use site, cc @kuanyingchou should this behavior change be taken care of in XProcessing?

reference: https://github.com/google/ksp/blob/main/docs/ksp2api.md#type-arguments-of-star-projections

@kuanyingchou
Copy link
Collaborator

Yes, I'm working on a change in XProcessing for this, but please note that Dagger doesn't work with KSP2 yet.

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

3 participants