Skip to content

Support generic input types - #819

Merged
oryan-block merged 3 commits into
masterfrom
bugfix/468
Oct 2, 2026
Merged

oryan-block merged 3 commits into
masterfrom
bugfix/468

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Fixes #468

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

Using a generic class as an input type, e.g. AuditWrapper<LanguageInput> with a content: T field, crashed with ClassCastException: 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 resolve T against. Now it's resolved relative to the containing input type, which covers both AuditWrapper<LanguageInput> and a subclass like LanguageAuditWrapper : AuditWrapper<LanguageInput>.

Also changed GenericType#replaceTypeVariable to keep the full type argument instead of its raw class. Otherwise AuditWrapper<List<LanguageInput>> still fails with "generic type information was lost". This is shared with resolver types too, but it just makes T -> Foo<Bar> behave the same as declaring Foo<Bar> directly.

I didn't go with the fix suggested in the issue (using mostSpecificType in parameterizedDeclaringTypeOrSuperType) since that changes how type variables are resolved for every resolver, not just input types.

🤖 Generated with Claude Code

oryan-block and others added 3 commits October 2, 2026 17:35
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>
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

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.

Generic Type Is Not Supported in Input Type

1 participant