fix(ksp): preserve generic type args for suspend functions returning non-generic typealiases + fix server leak in tests - #12708
Draft
graemerocher with Copilot wants to merge 4 commits into
Draft
fix(ksp): preserve generic type args for suspend functions returning non-generic typealiases + fix server leak in tests#12708graemerocher with Copilot wants to merge 4 commits into
graemerocher with Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix code for comments in review thread
fix(ksp): preserve generic type args for suspend functions returning non-generic typealiases + fix server leak in tests
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KSP was losing concrete type arguments when a suspend function returned a non-generic typealias (e.g.
typealias BarList = List<Bar>). Because the alias has notypeParameters,KSType.argumentswas empty, causingArgument.of(List, "T")with a literal"T"instead of the resolvedBar— resulting in aClassCastExceptionat runtime.Changes
AbstractKotlinElement.kt: When resolving type arguments, detect a non-genericKSTypeAlias(one with notypeParameters) and expand to its underlying type before iterating arguments. This recovers the concrete type parameters (e.g.Bar) that would otherwise be invisible.SuspendClient.kt/SuspendClientController.kt: Addtypealias BarList = List<Bar>and a/barsendpoint returningList<Bar>to exercise the fix.SuspendClientSpec.kt: Add regression testtestSuspendClientReturnsTypealiasToListthat callsgetBars(): BarListand asserts the response is correctly deserialized. Additionally, wrap all tests inuse { }blocks so theEmbeddedServeris always stopped after each test, preventing port/thread accumulation across the test JVM.