Skip to content

Keep the method type in sync with the return type in ConvertToRawType - #1202

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

With openrewrite/rewrite#9284, RewriteTest's type validation compares a method declaration's return type expression with the return type of its JavaType.Method. ConvertToRawTypeTest.methodReturnType fails under it:

/*~~(MethodDeclaration#returnTypeExpression type does not match the return type of the MethodType)~~>*/NginxContainer createContainer() {

ConvertToRawType changes the return type expression from the parameterized container type to its raw type, but the method type still returns the parameterized container type, so method matchers and later recipes see the old signature. The recipe now gives the method type the new return type, and gives the method name the same JavaType.Method instance, which type validation also requires.

The test fails with #9284's rewrite-java and passes with this change. The suite stays green against the current snapshot.

ConvertToRawType made a method's return type expression raw but left its
JavaType.Method returning the parameterized type. The method type now
gets the same raw return type, and the method name holds the same
JavaType.Method instance.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 20, 2026
@knutwannheden
knutwannheden merged commit 6736a67 into main Oct 20, 2026
2 checks passed
@knutwannheden
knutwannheden deleted the keep-method-type-in-sync branch October 20, 2026 12:32
@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

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant