IntelliJ "contents of array are written to but never read" warning seems to be wrong when casting from a parameter
Answered
Given the following sample code:
protected void setContext(Object contextHelper, Context cx) {
Object[] storage = (Object[]) contextHelper;
storage[0] = cx;
}
IntelliJ will mark the array object "storage" with a "contents of array are written to but never read" warning, but it is not true, the method caller might read it.
Or is IntelliJ actually analizing the caller too? That would be terrific.
Please sign in to leave a comment.
Please clarify what IntelliJ IDEA do you use? Is the issue reproduced for you with 2019.2 (https://www.jetbrains.com/idea/download)? Thank you
Actually it's from Android Studio:
Android Studio 3.4.2
Build #AI-183.6156.11.34.5692245, built on June 27, 2019
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Figured it would be better to post it here since it's IntelliJ based. If anyone could try this on the latest IntelliJ that would be great.
Issue is reproduced for me with IntelliJ IDEA v2018.3.2, but works correct in v2019.1.3, 2019.2. Should be fixed.