Skip to content

Keep method type in sync with migrated return type in MigratePoolingNHttpClientConnectionManager - #157

Merged
knutwannheden merged 1 commit into
mainfrom
keep-method-type-in-sync
Oct 20, 2026
Merged

knutwannheden merged 1 commit into
mainfrom
keep-method-type-in-sync

Conversation

@knutwannheden

Copy link
Copy Markdown
Contributor

openrewrite/rewrite#9284 adds a FindMissingTypes check that RewriteTest runs on every recipe's output. With it, MigratePoolingNHttpClientConnectionManagerTest.migratesSimpleConstructor and migratesWhenPassedAsArguments fail:

MethodDeclaration#returnTypeExpression type does not match the return type of the MethodType

The recipe rewrites a method's return type expression from PoolingNHttpClientConnectionManager to PoolingAsyncClientConnectionManager but leaves the declaration's JavaType.Method returning the 4.x type, so any later recipe reading the method type still sees the old class.

The fix updates the method type's return type together with the expression, and gives the method name that same JavaType.Method instance, which another FindMissingTypes check requires. It uses only API in released rewrite, so it can merge ahead of #9284. The existing tests catch the bug once #9284 is in, and they pass both with and without it after this change.

…HttpClientConnectionManager

Changing a method declaration's return type expression left its JavaType.Method returning the old type. Update the method type, and the name's type with the same instance, alongside the return type expression.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 20, 2026
@knutwannheden
knutwannheden merged commit 14ce450 into main Oct 20, 2026
2 checks passed
@knutwannheden
knutwannheden deleted the keep-method-type-in-sync branch October 20, 2026 11:03
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant