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

Can't use nullable types in Entities with Kotlin KSP #717

Closed
CorayThan opened this issue Dec 11, 2024 · 1 comment
Closed

Can't use nullable types in Entities with Kotlin KSP #717

CorayThan opened this issue Dec 11, 2024 · 1 comment

Comments

@CorayThan
Copy link
Contributor

I was hoping you could help me determine if this is the correct repository to report this error in. Given the stacktrace, I'm not sure if this is a problem with the Kotlin functionality you've recently added, or with kotlinpoet, or KSP itself.

Describe the bug
Using nullable values with Kotlin KSP causes an error. when trying to perform a build.

To Reproduce
I created a miniature repository that recreates the issue fully. Just run a gradle build in this project to fully recreate the problem.

kspnullerror repo

But all it takes is using KSP along with this code:

@Entity
class TestEntity(

    // Nullable Int causes failure
    val amount: Int?,

// Rest of the Entity

Expected behavior
I expect a gradle build to work.

Additional context
Full stacktrace:

[ksp] java.lang.IllegalStateException: KSType 'Comparable<Int>' has type arguments, which are not supported for ClassName conversion. Use KSType.toTypeName().
	at com.squareup.kotlinpoet.ksp.KsTypesKt.toClassName(KsTypes.kt:44)
	at com.querydsl.ksp.codegen.TypeExtractor.collectionType(TypeExtractor.kt:64)
	at com.querydsl.ksp.codegen.TypeExtractor.extract(TypeExtractor.kt:25)
	at com.querydsl.ksp.codegen.QueryModelExtractor.extractProperties$lambda$7(QueryModelExtractor.kt:79)
	at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
	at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:820)
	at com.querydsl.ksp.codegen.QueryModelExtractor.extractProperties(QueryModelExtractor.kt:82)
	at com.querydsl.ksp.codegen.QueryModelExtractor.processProperties(QueryModelExtractor.kt:65)
	at com.querydsl.ksp.codegen.QueryModelExtractor.process(QueryModelExtractor.kt:34)
	at com.querydsl.ksp.codegen.QueryDslProcessor.finish(QueryDslProcessor.kt:29)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$12$1.invoke(KotlinSymbolProcessingExtension.kt:359)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$12$1.invoke(KotlinSymbolProcessingExtension.kt:358)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:430)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:358)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:75)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze$lambda$9(KotlinToJVMBytecodeCompiler.kt:356)
	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:347)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runFrontendAndGenerateIrUsingClassicFrontend(KotlinToJVMBytecodeCompiler.kt:177)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:102)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:43)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:102)
	at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.kt:316)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1554)
Copy link
Contributor

This issue has been automatically closed because the author did not indicate they are willing to put in the effort needed to resolve it.

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

1 participant