google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.75k stars 259 forks source link

Unexpected containing declaration while working with typealias of typealias #1544

Open Th4n opened 10 months ago

Th4n commented 10 months ago

Hey, I'm working on an Android app and tried running Dagger with alpha support for KSP and received exception during the build. I'm not exactly whether it is KSP specific, or KSP + Dagger mix, however, the stacktrace directed me here.

Stacktrace of issue

e: [ksp] java.lang.IllegalStateException: Unexpected containing declaration for package.class.T, please file a bug at https://github.com/google/ksp/issues/new
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl$parentDeclaration$2.invoke(KSTypeParameterDescriptorImpl.kt:53)
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl$parentDeclaration$2.invoke(KSTypeParameterDescriptorImpl.kt:48)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl.getParentDeclaration(KSTypeParameterDescriptorImpl.kt:48)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl$parent$2.invoke(KSDeclarationDescriptorImpl.kt:57)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl$parent$2.invoke(KSDeclarationDescriptorImpl.kt:56)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl.getParent(KSDeclarationDescriptorImpl.kt:56)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KSTypeExtKt.hasSuppressWildcardsAnnotationInHierarchy(KSTypeExt.kt:203)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:353)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:336)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyTypeVariance(KSTypeVarianceResolver.kt:72)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspProcessingEnv.resolveWildcards$room_compiler_processing(KspProcessingEnv.kt:320)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:74)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:73)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType.getXTypeName(KspType.kt:73)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType.access$getXTypeName(KspType.kt:49)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:64)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:63)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspType.getTypeName(KspType.kt:63)
        at dagger.internal.codegen.xprocessing.XTypes.toStableString(XTypes.java:458)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
        at dagger.internal.codegen.xprocessing.XElements.toStableString(XElements.java:340)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.getMessageForElement(DaggerSuperficialValidation.java:637)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.append(DaggerSuperficialValidation.java:547)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.access$200(DaggerSuperficialValidation.java:491)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateTypeOf(DaggerSuperficialValidation.java:142)
        at dagger.internal.codegen.validation.InjectValidator.validateConstructor(InjectValidator.java:171)
        at dagger.internal.codegen.validation.InjectValidator.validateUncached(InjectValidator.java:154)
        at dagger.internal.codegen.base.Util.reentrantComputeIfAbsent(Util.java:33)
        at dagger.internal.codegen.validation.InjectValidator.validate(InjectValidator.java:137)
        at dagger.internal.codegen.validation.InjectBindingRegistryImpl.tryRegisterConstructor(InjectBindingRegistryImpl.java:252)
        at dagger.internal.codegen.validation.InjectBindingRegistryImpl.tryRegisterInjectConstructor(InjectBindingRegistryImpl.java:241)
        at dagger.internal.codegen.processingstep.InjectProcessingStep.process(InjectProcessingStep.java:73)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:82)
        at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:196)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:70)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:48)
        at dagger.spi.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:59)
        at dagger.spi.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:130)
        at dagger.spi.shaded.androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:305)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:303)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:409)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:303)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:88)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1497)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
        at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.rmi/sun.rmi.transport.Transport$1.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Unknown Source)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

I'm not exactly sure how to reproduce the exact issue (or even to narrow down where it's happening now), but my guess is that it is related to Kotlin type aliases with generic types. I've tried to reproduce this stacktrace on an empty project, however, didn't manage to get the exact error (but still got some errors that might help with the investigation).

Trying to reproduce the issue

I have an interface with multiple generic types, typealias called TypeAlias that's reducing generic types to one and second typealias called AnotherTypeAlias specifying that generic type. The following code only fails when injecting AnotherTypeAlias (injecting either TypeAlias<Any> or MyInterface<Any,Any> works fine). Also reducing generic types to one seems to fix the issue as well.

class Test {

    @Inject
    lateinit var member: AnotherTypeAlias

}

@Component(modules = [com.example.myapplication.Module::class])
interface Component {
    fun inject(test: Test)
}

@Module
class Module {
    @Provides
    fun provideMyInterface(): AnotherTypeAlias {
        return object : MyInterface<Any, Any> {
            override fun foo() {
            }
        }
    }
}

typealias AnotherTypeAlias = TypeAlias<Any>

typealias TypeAlias<T> = MyInterface<T, T>

interface MyInterface<T, E> {
    fun foo()
}

I got the following error:

> Task :app:kspDebugKotlin FAILED
e: [ksp] InjectProcessingStep was unable to process 'member' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.example.myapplication.Test
    => element (FIELD): member
    => type (ERROR field type): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] ModuleProcessingStep was unable to process 'com.example.myapplication.Module' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.example.myapplication.Module
    => element (METHOD): provideMyInterface()
    => type (ERROR return type): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] ComponentProcessingStep was unable to process 'com.example.myapplication.Component' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.example.myapplication.Module
    => element (METHOD): provideMyInterface()
    => type (EXECUTABLE method): ()error.NonExistentClass
    => type (ERROR return type): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: [ksp] BindingMethodProcessingStep was unable to process 'provideMyInterface()' because 'error.NonExistentClass' could not be resolved.

Dependency trace:
    => element (CLASS): com.example.myapplication.Module
    => element (METHOD): provideMyInterface()
    => type (ERROR return type): error.NonExistentClass

If type 'error.NonExistentClass' is a generated type, check above for compilation errors that may have prevented the type from being generated. Otherwise, ensure that type 'error.NonExistentClass' is on your classpath.
e: Error occurred in KSP, check log for detail

I'm not sure how can I be more helpful with the issue, but if there is anything else I could provide please let me know.

Dagger: 2.48 ksp: 1.9.0-1.0.12 kotlin-android: 1.9.0

neetopia commented 10 months ago

Looks like a KSP bug to me

akingyin1987 commented 9 months ago

I also have the same abnormality

zhangjianhd commented 7 months ago

I also have the same abnormality

Wrywulf commented 3 months ago

I get an error that seems to fit this issue as well.

Dagger 2.51.1 KSP: 1.9.23-1.0.20

I have a class:

@HiltViewModel(assistedFactory = ContributorsViewModel.Factory::class)
class ContributorsViewModel @AssistedInject constructor(
    @Assisted private val contributorsScreenArgs: ContributorsNavDirections.ContributorScreenArgs
) : ReduxViewModel<State, Action, Effect>() {

    @AssistedFactory
    interface Factory {
        fun create(args: ContributorsNavDirections.ContributorScreenArgs): ContributorsViewModel
    }

    private val loadContributors: SideEffect<State, Action> = { actions, _ ->. // COMPILATION ERROR
   //    private val loadContributors: (actions: Observable<Action>, state: StateAccessor<State>) -> Observable<out Action> = { actions, _ ->. // WORKS
      ...
    }

The problem is the type SideEffect<State, Action> which is defined (in a 3rd party library) using another typealias. As you can see in the comments, using the "inner" typealias directly works fine.

typealias SideEffect<S, A> = (actions: Observable<A>, state: StateAccessor<S>) -> Observable<out A>

typealias StateAccessor<S> = () -> S

The error log is a bit different from the OPs:

e: [ksp] dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException$UnexpectedException: 
  Validation trace:
    => element (CLASS): com.example.repos.impl.contributors.ContributorsViewModel
    => element (FIELD): loadContributors
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.from(DaggerSuperficialValidation.java:527)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.access$100(DaggerSuperficialValidation.java:491)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateTypeOf(DaggerSuperficialValidation.java:142)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElement(DaggerSuperficialValidation.java:306)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElements(DaggerSuperficialValidation.java:250)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateElement(DaggerSuperficialValidation.java:285)
        at dagger.internal.codegen.processingstep.SuperficialValidator.validationExceptionsUncached(SuperficialValidator.java:58)
        at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
        at dagger.internal.codegen.processingstep.SuperficialValidator.throwIfNearestEnclosingTypeNotValid(SuperficialValidator.java:47)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.lambda$process$0(TypeCheckingProcessingStep.java:92)
        at com.google.common.collect.SingletonImmutableBiMap.forEach(SingletonImmutableBiMap.java:70)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:72)
        at dagger.internal.codegen.processingstep.TypeCheckingProcessingStep.process(TypeCheckingProcessingStep.java:49)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.XProcessingStep.process(XProcessingStep.kt:59)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:132)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:310)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$8$1.invoke(KotlinSymbolProcessingExtension.kt:308)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:414)
        at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:308)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
        at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:77)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:256)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:247)
        at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:247)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:87)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:43)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1523)
        at jdk.internal.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.IllegalStateException: Unexpected containing declaration for com.freeletics.rxredux.StateAccessor.S, please file a bug at https://github.com/google/ksp/issues/new
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl$parentDeclaration$2.invoke(KSTypeParameterDescriptorImpl.kt:53)
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl$parentDeclaration$2.invoke(KSTypeParameterDescriptorImpl.kt:48)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.binary.KSTypeParameterDescriptorImpl.getParentDeclaration(KSTypeParameterDescriptorImpl.kt:48)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl$parent$2.invoke(KSDeclarationDescriptorImpl.kt:57)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl$parent$2.invoke(KSDeclarationDescriptorImpl.kt:56)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.symbol.impl.binary.KSDeclarationDescriptorImpl.getParent(KSDeclarationDescriptorImpl.kt:56)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeExtKt.hasSuppressWildcardsAnnotationInHierarchy(KSTypeExt.kt:205)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:353)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:336)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:342)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyJvmWildcardAnnotations(KSTypeVarianceResolver.kt:336)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KSTypeVarianceResolver.applyTypeVariance(KSTypeVarianceResolver.kt:72)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspProcessingEnv.resolveWildcards$room_compiler_processing(KspProcessingEnv.kt:347)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:74)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$xTypeName$2.invoke(KspType.kt:73)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.getXTypeName(KspType.kt:73)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.access$getXTypeName(KspType.kt:49)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:64)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType$typeName$2.invoke(KspType.kt:63)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dagger.spi.internal.shaded.androidx.room.compiler.processing.ksp.KspType.getTypeName(KspType.kt:63)
        at dagger.internal.codegen.xprocessing.XTypes.isWildcard(XTypes.java:309)
        at dagger.internal.codegen.xprocessing.XTypes.getKindName(XTypes.java:541)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.append(DaggerSuperficialValidation.java:557)
        at dagger.internal.codegen.base.DaggerSuperficialValidation$ValidationException.access$400(DaggerSuperficialValidation.java:491)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateType(DaggerSuperficialValidation.java:346)
        at dagger.internal.codegen.base.DaggerSuperficialValidation.validateTypeOf(DaggerSuperficialValidation.java:132)
        ... 48 more
ericytsang commented 4 weeks ago

i ran into DaggerSuperficialValidation$ValidationException$UnexpectedException as well...

it turned out to be a very misleading error that was caused by a dumb mistake.

it involved the following classes:

  1. class A
    • this is the class that showed up in the stack trace
    • it has no obvious problems
  2. class B:
    • this class is using constructor injection to inject class A into itself
    • this class also has a compiler error (in my case, it has 2 companion objects due to bad git merge...)

the solution in my case was to resolve the compiler error in class B, which fixed the error message.

my mistake was silly, but i think the error is misleading. i'd rather get a compiler error that points me to the correct file.