go: dispatch *tree.Else in GoVisitor.Visit so RPC sends the body#7592
Merged
jkschneider merged 1 commit intomainfrom May 7, 2026
Merged
go: dispatch *tree.Else in GoVisitor.Visit so RPC sends the body#7592jkschneider merged 1 commit intomainfrom
*tree.Else in GoVisitor.Visit so RPC sends the body#7592jkschneider merged 1 commit intomainfrom
Conversation
`JavaSender.VisitIf` constructs a synthetic `*tree.Else` to mirror Java's `J.If.Else` on the wire, but `GoVisitor.Visit`'s type switch had no case for it — the node fell through to `default: return t`, so preVisit (id/prefix/markers) ran but `JavaSender.VisitElse` never did and the body was never sent. The receive queue desynchronized for the rest of the parse, surfacing as `Expected CHANGE with positions in receiveList` or `Space cannot be cast to JRightPadded` depending on which sibling node tripped first. Add the dispatch entry, the matching `VisitorI` method, and a default `GoVisitor.VisitElse` that visits prefix / markers / body so language-level traversal terminates correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JavaSender.VisitIfconstructs a synthetic*tree.Elseto mirror Java'sJ.If.Elseon the wire, butGoVisitor.Visit's type switch had no case for it. The node fell through todefault: return t, so preVisit (id/prefix/markers) ran butJavaSender.VisitElsenever did and the body was never sent. The receive queue desynchronized for the rest of the parse, surfacing on the Java side as either:Expected CHANGE with positions in receiveList, but got ADD ...(inRpcReceiveQueue.receiveListwhenever a list-typed field is the first to land on the misaligned offset), orClassCastException: org.openrewrite.java.tree.Space cannot be cast to org.openrewrite.java.tree.JRightPadded(whenJavaReceiver.visitElseis the unlucky one that reads the next misaligned message).The integ test
GolangParserIntegTest.ifElseStatementwas already failing onmainfor this reason; downstream the moderne-cli was hitting the same desync on every gorilla/mux file with anif/elsepast it (29 parse errors across 64 files in a 3-repo sample).Fix
Add the dispatch entry, the matching
VisitorImethod, and a defaultGoVisitor.VisitElsethat visits prefix / markers / body so language-level traversal terminates correctly.Test plan
:rewrite-go:integTest— full suite green, includingGolangParserIntegTest.ifElseStatement(was failing).ParseProjectIfElseTest.ifElseInProjectFile— fails on the parent commit, passes here.