google / ksp

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

KSP Room PagingSource error #2120

Open yoobi opened 1 month ago

yoobi commented 1 month ago

Hello ! I'm using the following version

kotlin = "1.9.24"
ksp = "1.9.24-1.0.20"
room = 2.6.1
androidx-paging = "3.3.2"
@Entity
class UserLocalModel(@PrimaryKey val id: Int, val name: String)

@Dao
interface UserCollectionDao {
    @Query("SELECT id FROM UserLocalModel")
    fun observeUserIds(): PagingSource<Int, Int>
}

The error is:

[ksp] java.lang.IllegalArgumentException: invalid type parameter: int
    at com.squareup.javapoet.Util.checkArgument(Util.java:53)
    at com.squareup.javapoet.ParameterizedTypeName.<init>(ParameterizedTypeName.java:51)
    at com.squareup.javapoet.ParameterizedTypeName.<init>(ParameterizedTypeName.java:38)
    at com.squareup.javapoet.ParameterizedTypeName.get(ParameterizedTypeName.java:114)
    at androidx.room.compiler.codegen.XClassName.parametrizedBy(XTypeName.kt:305)
    at androidx.room.solver.query.result.MultiTypedPagingSourceQueryResultBinder.<init>(MultiTypedPagingSourceQueryResultBinder.kt:43)
    at androidx.room.solver.binderprovider.MultiTypedPagingSourceQueryResultBinderProvider.provide(MultiTypedPagingSourceQueryResultBinderProvider.kt:59)
    at androidx.room.solver.binderprovider.QueryResultBinderProviderWithRequiredArtifact.provide(QueryResultBinderProviderWithRequiredArtifact.kt:55)
    at androidx.room.solver.TypeAdapterStore.findQueryResultBinder(TypeAdapterStore.kt:458)
    at androidx.room.solver.TypeAdapterStore.findQueryResultBinder(TypeAdapterStore.kt:448)
    at androidx.room.processor.DefaultMethodProcessorDelegate.findResultBinder(MethodProcessorDelegate.kt:174)
    at androidx.room.processor.InternalQueryProcessor.getQueryMethod(QueryMethodProcessor.kt:217)
    at androidx.room.processor.InternalQueryProcessor.processQuery(QueryMethodProcessor.kt:145)
    at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:72)
    at androidx.room.processor.QueryMethodProcessor$process$1.invoke(QueryMethodProcessor.kt:66)
    at androidx.room.processor.Context.collectLogs(Context.kt:192)
    at androidx.room.processor.QueryMethodProcessor.process(QueryMethodProcessor.kt:66)
    at androidx.room.processor.DaoProcessor.process(DaoProcessor.kt:134)
    at androidx.room.processor.DatabaseProcessor$doProcess$daoMethods$3.invoke(DatabaseProcessor.kt:122)
    at androidx.room.processor.DatabaseProcessor$doProcess$daoMethods$3.invoke(DatabaseProcessor.kt:96)
    at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
    at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:170)
    at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194)
    at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:816)
    at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:125)
    at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:60)
    at androidx.room.DatabaseProcessingStep$process$databases$1$1.invoke(DatabaseProcessingStep.kt:68)
    at androidx.room.DatabaseProcessingStep$process$databases$1$1.invoke(DatabaseProcessingStep.kt:64)
    at androidx.room.processor.Context.collectLogs(Context.kt:192)
    at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:64)
    at androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:130)
    at 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.GeneratedMethodAccessor103.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)
yoobi commented 1 month ago

When changing query to below, there is no compile issue

@Query("SELECT * FROM UserLocalModel")
fun observeUserIds(): PagingSource<Int, Int>