Allow computeIfAbsent on a different collection in functional conversion - #1478
Conversation
JUnit Test Overview ReportGenerated on: 31839487823 Overall Statistics
Test Summary by Plugin
Disabled Tests DetailsNo disabled tests found! 🎉 Generated by the Test Source Inventory workflow |
There was a problem hiding this comment.
Pull request overview
Adds focused regression coverage for functional-loop conversion behavior around Map.computeIfAbsent(...), ensuring conversion is allowed when mutating a different collection than the one being traversed, while remaining blocked when mutating the backing map of a traversed map view.
Changes:
- Introduces a dedicated JUnit test class reproducing issue #1476 with an enhanced-for over a
Listthat callsmap.computeIfAbsent(...)and expects conversion tolist.forEach(...). - Adds a negative test asserting conversion remains blocked when iterating
map.entrySet()and mutating the backingmapviacomputeIfAbsent(...).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Scope
Adds an isolated executable reproduction for #1476:
listiteration withmap.computeIfAbsent(...)must convert tolist.forEach(...)because the mutated map is not the traversed collection;map.entrySet()iteration withmap.computeIfAbsent(...)must remain unchanged because the backing map is the traversed structural owner.The first CI run intentionally establishes whether the fault is still in production logic or whether the previously disabled integration test is stale. A production change will be added only if the positive regression fails; the receiver-sensitive safety guard must remain intact.
Fixes #1476.