Skip to content

AssertEqualsNullToAssertNull: support Kotlin via LST manipulation#1053

Merged
timtebeek merged 3 commits into
mainfrom
tim/kotlin-recipe-support
Jul 17, 2026
Merged

AssertEqualsNullToAssertNull: support Kotlin via LST manipulation#1053
timtebeek merged 3 commits into
mainfrom
tim/kotlin-recipe-support

Conversation

@timtebeek

Copy link
Copy Markdown
Member

AssertEqualsNullToAssertNull used a JavaTemplate, which can only emit Java, so it crashed with "Expected a template that would generate exactly one statement to replace one statement, but generated 0" when the assertEquals(a, null) call was in a Kotlin source (e.g. assertEquals(values[0], null)).

This reworks the recipe to transform via direct LST manipulation instead — renaming assertEquals to assertNull, dropping the null argument, resolving the correct assertNull overload, and updating imports — which works uniformly for Java and Kotlin. Java behavior is unchanged; a new Kotlin test covers all four argument shapes plus the assertEquals to assertNull import rewrite.

@timtebeek
timtebeek marked this pull request as ready for review July 17, 2026 10:39
@timtebeek
timtebeek merged commit 224c5eb into main Jul 17, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jul 17, 2026
@timtebeek
timtebeek deleted the tim/kotlin-recipe-support branch July 17, 2026 10:49
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