Skip to content

Fix performance of KSClassDeclaration.getAllSuperTypes - #3213

Open
jaschdoc wants to merge 4 commits into
mainfrom
perf-supertypes
Open

jaschdoc wants to merge 4 commits into
mainfrom
perf-supertypes

Conversation

@jaschdoc

Copy link
Copy Markdown
Collaborator

This change brings down the complexity from what looks like exponential to a polynomial time function by maintaining a visited set. Additionally also guards cyclic type aliases (although this cannot occur, we do not want non-termination if it were to happen).

@jaschdoc jaschdoc changed the title Fix performance in KSClassDeclaration.getAllSuperTypes Fix performance of KSClassDeclaration.getAllSuperTypes Sep 17, 2026
@jaschdoc
jaschdoc marked this pull request as ready for review September 18, 2026 10:14
Comment thread api/src/main/kotlin/com/google/devtools/ksp/utils.kt
Comment thread api/src/main/kotlin/com/google/devtools/ksp/utils.kt Outdated
Comment thread api/src/main/kotlin/com/google/devtools/ksp/utils.kt
Comment thread kotlin-analysis-api/testData/diamondInheritance.kt Outdated
@jaschdoc
jaschdoc force-pushed the perf-supertypes branch 2 times, most recently from 9f8f22a to db09416 Compare September 18, 2026 13:54
@jaschdoc
jaschdoc enabled auto-merge September 18, 2026 15:18
Comment thread api/src/main/kotlin/com/google/devtools/ksp/utils.kt Outdated
@jaschdoc
jaschdoc requested a review from troelsbjerre October 22, 2026 10:14
@jaschdoc
jaschdoc disabled auto-merge October 22, 2026 10:15
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

Successfully merging this pull request may close these issues.

2 participants