Support generic input types - #819
Merged
Merged
Conversation
Resolve input field types relative to the containing input type instead of the field type itself, so type variables like `T` in `AuditWrapper<T>` can be resolved. Also keep the full type argument when replacing type variables so nested generics (e.g. `List<Foo>`) aren't erased to their raw class. Fixes #468 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
This was referenced Oct 3, 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.



Fixes #468
Checklist
Description
Using a generic class as an input type, e.g.
AuditWrapper<LanguageInput>with acontent: Tfield, crashed withClassCastException: TypeVariableImpl cannot be cast to class java.lang.Class. The scanner was resolving each input field's type relative to the field type itself (T) instead of the input class it's declared on, so there was nothing to resolveTagainst. Now it's resolved relative to the containing input type, which covers bothAuditWrapper<LanguageInput>and a subclass likeLanguageAuditWrapper : AuditWrapper<LanguageInput>.Also changed
GenericType#replaceTypeVariableto keep the full type argument instead of its raw class. OtherwiseAuditWrapper<List<LanguageInput>>still fails with "generic type information was lost". This is shared with resolver types too, but it just makesT -> Foo<Bar>behave the same as declaringFoo<Bar>directly.I didn't go with the fix suggested in the issue (using
mostSpecificTypeinparameterizedDeclaringTypeOrSuperType) since that changes how type variables are resolved for every resolver, not just input types.🤖 Generated with Claude Code