Go: add StatementExpression, fix variadic params, remove receiver overrides#7261
Merged
jkschneider merged 2 commits intomainfrom Apr 2, 2026
Merged
Go: add StatementExpression, fix variadic params, remove receiver overrides#7261jkschneider merged 2 commits intomainfrom
jkschneider merged 2 commits intomainfrom
Conversation
…d parse input order
Add Go.StatementExpression (both Java and Go sides) to wrap
MethodDeclaration in expression contexts, following the same pattern
as Cs.StatementExpression in rewrite-csharp. Func literals like
`func(x int) int { return x }` are parsed as MethodDeclaration (a
Statement) but need to appear in returns, assignments, and call args.
Fix variadic parameter handling: detect `...T` in mapFieldListAsParams,
store the `...` prefix in VariableDeclarations.Varargs, and pass only
the element type through mapTypeExpr. Previously `...T` was mapped as
Unary{Spread, T} in the TypeExpr field, which violated the TypeTree
constraint.
Fix RPC parse input order: check Text before Path/SourcePath so text-
based inputs (from integration tests) aren't mistakenly treated as
file paths.
Add 8 integration tests. 51 of 52 pass (goroutineAndDefer fails due
to directly-invoked func literal `go func(){}()` padding mismatch).
934ca1f to
39bea46
Compare
This was referenced Apr 3, 2026
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
Replaces the receiver overrides from #7258 with proper parser-level fixes:
Go.StatementExpression (new LST element): Wraps
MethodDeclarationin expression contexts, following the same pattern asCs.StatementExpressionin rewrite-csharp. Go function literals (func(x int) int { return x }) are parsed asMethodDeclaration(aStatement) but appear in returns, assignments, and call arguments which requireExpression.Variadic parameter fix: Detect
...TinmapFieldListAsParams, store the...prefix inVariableDeclarations.Varargs, and pass only the element type throughmapTypeExpr. Previously...Twas mapped asUnary{Spread, T}in the TypeExpr field, violating theTypeTreeconstraint.RPC parse input order: Check text-based inputs before file-path inputs so inline source code (from integration tests) isn't mistakenly treated as a file path.
Reverts #7258 receiver overrides — the proper fix is at the parser/sender level, not in the receiver.
Test plan