Skip to content

Fix unsed variable handling for update expressions - #274

Open
shin19991207 wants to merge 1 commit into
eclipse-jdtls:mainfrom
shin19991207:fix-testUnusedVariableAsSwitchStatement
Open

Fix unsed variable handling for update expressions#274
shin19991207 wants to merge 1 commit into
eclipse-jdtls:mainfrom
shin19991207:fix-testUnusedVariableAsSwitchStatement

Conversation

@shin19991207

Copy link
Copy Markdown
Contributor

Fixed javac unused-local analysis so update expressions are not count as meaningful variable reads.

Previously, an expression statement like e += "" was treated as a read of e. UnusedTreeScanner added e to usedElements which caused the unused-local diagnostic to be skipped.

This change handles compound assignments (+=) and unary increment/decrement expressions (++, --) as writes only (using lhsInAssignment), so they do not mark the variable as used.

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@datho7561
datho7561 force-pushed the fix-testUnusedVariableAsSwitchStatement branch from 196cc2b to de3251b Compare May 7, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant