"unbalanced read/write" hint incorrect for record components
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 16
### What happened
`vmap` in the following record declaration gets `The collection is never added to`. It might be related to #4545, but it might be different. If the `unbalanced read/write with collections` hint is set to `current line` then the warning is not seen.
If the body of `foo` is changed to
```
dt.vmap.get("k1");
return null;
```
then the hint does not appear.
```
package play.warnings;
import java.util.Map;
public class Warnings {
public record DiscsTables(Integer discs, Map vmap) {};
public Object foo(DiscsTables dt) {
return dt.vmap.get("k1");
}
}
```
### How to reproduce
_No response_
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Linux harmony 5.19.16-76051916-generic #202210150742~1666053244~22.04~cf07008 SMP PREEMPT_DYNAMIC Tue O x86_64 x86_64 x86_64 GNU/Linux
### JDK
openjdk version "19" 2022-09-20 OpenJDK Runtime Environment (build 19+36-2238) OpenJDK 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
_No response_
### Are you willing to submit a pull request?
No
### Code of Conduct
Yes
Contributor guide
Research direction
No source file or test is named. Start by locating the implementation of the “unbalanced read/write with collections” hint and reproduce the record example with the hint enabled. Compare the analysis of the record component accessor with direct dt.vmap usage; done when the valid record-component access no longer produces the incorrect warning and existing hint tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100