Skip to content

Python: Add parameter field_type attribution and call-site type arguments#6795

Merged
knutwannheden merged 3 commits intomainfrom
add-type-attribution-tests
Feb 23, 2026
Merged

Python: Add parameter field_type attribution and call-site type arguments#6795
knutwannheden merged 3 commits intomainfrom
add-type-attribution-tests

Conversation

@knutwannheden
Copy link
Copy Markdown
Contributor

Summary

  • Add param_type_info() to PythonTypeMapping so function parameter J.Identifier nodes get JavaType.Variable field_type (matching how visit_Name and visit_Attribute already work)
  • Use call signature returnTypeId for call-site-specific return types (e.g., int for identity(42) instead of generic T)
  • Populate _declared_formal_type_names on method invocation types from function descriptor type parameters
  • Bump ty-types to 0.0.19.dev20260223102528 for callSignature typeArguments/returnTypeId support

Test plan

  • test_param_identifier_field_type — verifies J.Identifier.field_type is JavaType.Variable for typed function parameters
  • test_generic_call_site_return_type — verifies identity(42) gets Primitive.Int return type and ['T'] declared formal type names
  • test_generic_class_type_params — verifies type parameters on generic class Box[T]
  • All 416 tree tests pass with no regressions

- Add type attribution tests to 13 existing parser test files covering
  method invocations, binary ops, type hints, collection literals, imports,
  field access, class instances, method declarations, async defs, for loops,
  unary ops, ternaries, and lambdas
- Add `method_declaration_type()` to type_mapping.py to build JavaType.Method
  for function declarations using ty-types descriptor data with annotation fallback
- Add type attribution to ParameterizedType nodes in type hint expressions
- Fix pre-existing assign_test.py bug (simple_name access, FQN startswith)
- Add typing.Text test to test_type_attribution.py
- Bump ty-types dependency to >=0.0.19.dev20260223093555
- Add param_type_info() to PythonTypeMapping for function parameter
  Identifier nodes to get JavaType.Variable field_type
- Update __convert_name() and map_arg() to flow field_type through to
  J.Identifier and NamedVariable
- Use call signature returnTypeId for call-site-specific return types
  (e.g. int for identity(42) instead of generic T)
- Populate _declared_formal_type_names on method invocation types from
  function descriptor type parameters
- Bump ty-types to 0.0.19.dev20260223102528 for callSignature
  typeArguments/returnTypeId support
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Feb 23, 2026
@knutwannheden knutwannheden changed the title Add parameter field_type attribution and call-site type arguments Python: Add parameter field_type attribution and call-site type arguments Feb 23, 2026
@knutwannheden knutwannheden merged commit 77d6ec5 into main Feb 23, 2026
1 check passed
@knutwannheden knutwannheden deleted the add-type-attribution-tests branch February 23, 2026 10:53
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant