Skip to content

feat(jdk-codemodel): resolve Symbol.LocalVariable to its declaring LocalVariableDeclaration#110

Merged
deer merged 1 commit into
mainfrom
symbol_local_variable
Jul 7, 2026
Merged

feat(jdk-codemodel): resolve Symbol.LocalVariable to its declaring LocalVariableDeclaration#110
deer merged 1 commit into
mainfrom
symbol_local_variable

Conversation

@deer

@deer deer commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Extends Symbol.LocalVariable with an Optional<LocalVariableDeclaration> that links a local variable identifier back to the statement that declared it, mirroring how Symbol.Field and Symbol.Parameter already resolve to their descriptors.

JdkStatementConverter now calls a new registerLocalVariableDeclaration method on JdkExpressionConverter whenever it converts a VariableTree into a LocalVariableDeclaration, populating a map keyed by the resolved javac Element. When JdkExpressionConverter.resolveSymbol later encounters an IdentifierTree whose element kind is LOCAL_VARIABLE, it looks up that map to attach the declaring LocalVariableDeclaration, correctly handling shadowed variables of the same name in nested blocks since resolution is keyed by the distinct javac Element, not by name.

@deer deer merged commit e75e947 into main Jul 7, 2026
1 check passed
@deer deer deleted the symbol_local_variable branch July 7, 2026 08:10
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