Fix Java instrumentation compilation error for generic methods#1962
Fix Java instrumentation compilation error for generic methods#1962aseembits93 wants to merge 3 commits intomainfrom
Conversation
When instrumenting tests for generic methods like `<T extends Comparable<T>> List<T> mergeSorted(...)`, the extracted return type `List<T>` was used as a cast in the instrumented test class where `T` is not in scope, causing "cannot find symbol: class T" compilation errors. Added `_erase_method_type_params()` to detect method-level type parameters via tree-sitter and erase them from the return type: bare type variables become `Object`, parameterized uses become wildcards (e.g. `List<T>` → `List<?>`). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @aseembits93's task in 2m 59s —— View job PR Review Summary
Prek / Mypy ChecksNo issues. Code ReviewMissing test coverage (medium) — The PR description claims "6 new tests covering: generic
Per
Without the last case in particular, a regression where class-level generics get accidentally erased would go undetected. Fix this → Docstring on Core fix is correct — The tree-sitter AST approach to detect method-level
The reviewer's concern is addressed — All new test assertions use full string equality ( Duplicate DetectionNo duplicates detected. The Last updated: 2026-04-02T00:29Z |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
misrasaurabh1
left a comment
There was a problem hiding this comment.
the test should assert the whole string for correctness, not a substring assert
Summary
<T extends Comparable<T>> List<T> mergeSorted(...)), the return typeList<T>was used as a cast in the generated test class whereTis not in scope, causingcannot find symbol: class Tcompilation errors_erase_method_type_params()to detect method-level type parameters via tree-sitter and replace them: bare type variables →Object, parameterized uses → wildcards (e.g.List<T>→List<?>,Map<K, V>→Map<?, ?>)Test plan
List<T>, bareT, multi-paramMap<K, V>, non-generic methods, class-level genericscodeflash --file CollectionUtils.java --function mergeSortedno longer fails with compilation error🤖 Generated with Claude Code