Skip to content

fix(jdk-codemodel): resolve declared variable and parameter types to TypeUsage in source AST#10

Merged
deer merged 1 commit intomainfrom
variable_param_types
Apr 8, 2026
Merged

fix(jdk-codemodel): resolve declared variable and parameter types to TypeUsage in source AST#10
deer merged 1 commit intomainfrom
variable_param_types

Conversation

@deer
Copy link
Copy Markdown
Collaborator

@deer deer commented Apr 8, 2026

LocalVariableDeclaration, EnhancedFor, CatchClause, and LambdaParameter were storing source-form type name strings (via .toString() on javac tree nodes) instead of resolved TypeUsage objects, preventing these nodes from participating in type-system analysis.

The fix threads the existing type-resolution context (Trees, CompilationUnitTree, typeResolver) into JdkStatementConverter via a new setTypeContext() method — mirroring the pattern already used by JdkExpressionConverter. A resolveTypeUsage(Tree) helper is added to both converters that follows the same TreePath → TypeMirror → TypeUsage path already used for method return types, field types, and formal parameters. JdkInitializer wires the statement converter into context alongside the expression converter. Node schemas and marshalling are updated accordingly.

var-inferred types and unresolvable types fall back to UnknownTypeUsage, consistent with how the expression converter handles errors.

@deer deer merged commit 7f70329 into main Apr 8, 2026
1 check passed
@deer deer deleted the variable_param_types branch April 8, 2026 11:06
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