Skip to content

Drop unused declaring type and rename GenericType to GenericTypeResolver - #845

Merged
oryan-block merged 3 commits into
masterfrom
refactor/drop-declaring-type
Oct 10, 2026
Merged

oryan-block merged 3 commits into
masterfrom
refactor/drop-declaring-type

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Checklist

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

Description

Follow up to #825.

Since #825, type variables are resolved against the most specific type, so RelativeTo.declaringType was only used in an error message. I folded RelativeTo into GenericType and removed relativeToPotentialParent and relativeToType, so the field resolvers don't pass a declaring type anymore. Also removed getGenericSuperType and getGenericInterface, which weren't used.

Some of the names didn't make much sense without the declaring type, so I renamed them too:

  • GenericType -> GenericTypeResolver, unwrapGenericType -> resolve, and the fields holding it -> typeResolver
  • mostSpecificType -> containingType
  • replaceTypeVariable -> resolveTypeVariables
  • isTypeAssignableFromRawClass was named backwards (it checks if the type is a subtype of the class), so it's now a ParameterizedType.isSubtypeOf extension and the isListType helpers are gone

I also added a KDoc on resolve explaining what the "real" type is.

Two error messages changed:

  • Could not resolve type variable no longer says of <declaring type>. TypeUtils.toLongString already prints the class or method declaring the variable, so nothing is lost.
  • Unable to find generic type of class ... is gone. It could only happen if a property's declaring class wasn't a superclass of the data class, and the scanner never finds a property like that.

No other behaviour change. Existing tests pass.

🤖 Generated with Claude Code

oryan-block and others added 3 commits October 9, 2026 18:04
Since type variables are resolved against the most specific type, the
declaring type was only used in an error message. Fold RelativeTo into
GenericType and stop passing a declaring type from the field resolvers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add ParameterizedType.isSubtypeOf and use it in TypeClassMatcher in place of GenericType.isTypeAssignableFromRawClass
- Remove the isListType helpers in favor of the same check
- Rename mostSpecificType to containingType and document unwrapGenericType
- Rename GenericType to GenericTypeResolver and unwrapGenericType to resolve
- Rename the fields holding it to typeResolver

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@oryan-block
oryan-block merged commit 60adaff into master Oct 10, 2026
6 checks passed
@oryan-block
oryan-block deleted the refactor/drop-declaring-type branch October 10, 2026 20:49
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.

1 participant