raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.23k stars 134 forks source link

[KSP] Destinations generation issue #654

Closed MaxMichel2 closed 4 months ago

MaxMichel2 commented 5 months ago

Compose destinations version: 1.10.2 Kotlin version: 1.9.24 KSP version: 1.9.24-1.0.20 AGP version: 8.5.0 Gradle wrapper version: 8.7 Compose BOM version: 2024.06.00

I am currently trying to update my project to work with AGP 8+ (we're currently running AGP 7.3.1) and after a successful sync and a build attempt, the KSP task seems to run into an issue I can't quite pin down.

> Task :presentation-client:kspEaccDebugKotlin FAILED
e: [ksp] java.lang.NullPointerException
    at com.ramcosta.composedestinations.ksp.commons.UtilsKt.toImportable(Utils.kt:125)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper.getDestinationStyleType(KspToCodeGenDestinationsMapper.kt:351)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper.toDestination(KspToCodeGenDestinationsMapper.kt:112)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper.access$toDestination(KspToCodeGenDestinationsMapper.kt:67)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper$map$1.invoke(KspToCodeGenDestinationsMapper.kt:78)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper$map$1.invoke(KspToCodeGenDestinationsMapper.kt:78)
    at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
    at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:816)
    at com.ramcosta.composedestinations.ksp.processors.KspToCodeGenDestinationsMapper.map(KspToCodeGenDestinationsMapper.kt:78)
    at com.ramcosta.composedestinations.ksp.processors.Processor.process(Processor.kt:55)
    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 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    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:833)

e: Error occurred in KSP, check log for detail

Having looked in the code, there is a !! used for a simplified name which seems to be the cause of the issue.

I'm unsure as to what is actually going on a why this breaks down but I don't think it's linked to my project. I'll try to build the library locally and publish it on mavenLocal to test some things and if I find anything, I'll try to submit a PR

MaxMichel2 commented 5 months ago

After some digging, I found the issue (it was a typo that caused the issue) but I found that the actual error was hidden and created a PR to fix this