From 8df2284730be6403562c8ed4ed985d48bedc9ba6 Mon Sep 17 00:00:00 2001 From: bangbang93 Date: Tue, 14 Apr 2026 12:52:35 +0800 Subject: [PATCH] fix(ksp): skip parameterized supertypes in TypeExtractor.fallbackType() TypeExtractor.fallbackType() crashed with IllegalStateException when processing MongoDB @Document classes with ObjectId fields. The function was calling toClassName() on Comparable, a parameterized type which is not supported by KotlinPoet's toClassName(). Fix: Check supertype.arguments.isEmpty() before calling toClassName() to skip parameterized supertypes in the Comparable check. Fixes #1688 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt b/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt index 23e6722f9e..4b4b7ae501 100644 --- a/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt +++ b/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt @@ -65,8 +65,9 @@ class TypeExtractor( Comparable::class.java.canonicalName, java.lang.Comparable::class.qualifiedName ) - declaration.getAllSuperTypes().any { - comparableNames.contains(it.toClassName().canonicalName) + declaration.getAllSuperTypes().any { supertype -> + // Skip parameterized types (e.g. Comparable) — toClassName() throws for them + supertype.arguments.isEmpty() && comparableNames.contains(supertype.toClassName().canonicalName) } } else { false