Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<ObjectId>) — toClassName() throws for them
supertype.arguments.isEmpty() && comparableNames.contains(supertype.toClassName().canonicalName)
Comment on lines +69 to +70
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new supertype.arguments.isEmpty() guard prevents Comparable<T> (which is almost always parameterized) from ever being recognized as comparable. That avoids the crash, but it also changes behavior: types like ObjectId : Comparable<ObjectId> will now be treated as SimpleType.Simple (SimplePath) instead of SimpleType.Comparable (ComparablePath), likely reducing supported comparison operators.

Instead of skipping parameterized supertypes, compare using the supertype declaration (e.g., supertype.declaration.qualifiedName?.asString() or supertype.declaration.toClassName().canonicalName) so you can safely detect Comparable regardless of type arguments without calling toClassName() on the KSType itself.

Suggested change
// Skip parameterized types (e.g. Comparable<ObjectId>) — toClassName() throws for them
supertype.arguments.isEmpty() && comparableNames.contains(supertype.toClassName().canonicalName)
comparableNames.contains(supertype.declaration.qualifiedName?.asString())

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +70
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes a crash scenario around parameterized supertypes, but there is no regression test covering fallbackType() with a type that implements Comparable<T> (e.g., MongoDB ObjectId). Adding a focused unit/integration test that exercises TypeExtractor.fallbackType() for a parameterized Comparable supertype would prevent reintroducing the toClassName() IllegalStateException and ensure the resulting QPropertyType is correct.

Suggested change
// Skip parameterized types (e.g. Comparable<ObjectId>) — toClassName() throws for them
supertype.arguments.isEmpty() && comparableNames.contains(supertype.toClassName().canonicalName)
val supertypeDeclaration = supertype.declaration as? KSClassDeclaration
val qualifiedName = supertypeDeclaration?.qualifiedName?.asString()
comparableNames.contains(qualifiedName)

Copilot uses AI. Check for mistakes.
}
} else {
false
Expand Down
Loading