Open Th4n opened 10 months ago
Looks like a KSP bug to me
I also have the same abnormality
I also have the same abnormality
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
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:
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.
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
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 calledAnotherTypeAlias
specifying that generic type. The following code only fails when injectingAnotherTypeAlias
(injecting eitherTypeAlias<Any>
orMyInterface<Any,Any>
works fine). Also reducing generic types to one seems to fix the issue as well.I got the following error:
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