Skip to content

fix(imperative-codemodel): distinguish bare return from return null#16

Merged
deer merged 1 commit intomainfrom
return_fix
Apr 9, 2026
Merged

fix(imperative-codemodel): distinguish bare return from return null#16
deer merged 1 commit intomainfrom
return_fix

Conversation

@deer
Copy link
Copy Markdown
Collaborator

@deer deer commented Apr 9, 2026

Return.expression was non-optional, forcing JdkStatementConverter to substitute NullLiteral for bare return; statements. This made void returns indistinguishable from explicit return null; in the captured AST.

Return.expression is now Optional<Expression>. Return.of(CodeModel) is added for void returns, and Return.of(Expression) continues to serve value-returning statements. visitReturn passes Optional.empty() for bare returns instead of a fabricated null literal. Marshalling updated to Optional<Marshalled<Expression>> throughout.

New test shouldCaptureBareReturnAsEmptyOptional verifies the fix. Five existing callsites updated to .expression().orElseThrow().

@deer deer merged commit 2aa95bf into main Apr 9, 2026
1 check passed
@deer deer deleted the return_fix branch April 9, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant