Skip to content

KSP: TypeExtractor crashes on parameterized supertypes (ObjectId with MongoDB) #1688

@bangbang93

Description

@bangbang93

Important Notice

  • I am willing to put in the work and submit a PR to resolve this issue.

Describe the bug

querydsl-ksp-codegen:7.1 crashes with IllegalStateException when processing MongoDB @document classes that have ObjectId fields.

To Reproduce

  1. Create a Spring Data MongoDB @document class with an ObjectId field
  2. Add querydsl-ksp-codegen to build.gradle.kts
  3. Run ./gradlew kspKotlin

Expected behavior

KSP processor should generate QAgent.kt query class.

Actual behavior

Build fails with: IllegalStateException: KSType 'Comparable<(ObjectId..ObjectId?)>' has type arguments

Root cause

In TypeExtractor.kt:69, fallbackType() calls toClassName() on Comparable without checking if it is parameterized.

Proposed fix

Skip supertypes with type arguments before calling toClassName():

declaration.getAllSuperTypes().any { supertype ->
    supertype.arguments.isEmpty() && comparableNames.contains(supertype.toClassName().canonicalName)
}

Environment

  • OS: Linux
  • Kotlin: 2.3.20
  • querydsl-ksp-codegen: 7.1
  • kotlinpoet-ksp: 2.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions