Skip to content

[PatternMatchingInstanceof] Make negated matches optional #4930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PhilippWendler
Copy link

This introduces a configuration option that allows one to disable the replacement of casts that are implied by a negated instanceof expression and are not within the same expression as the instanceof. This affects casts in else branches and those below an if statement where the then branch always returns from the method. Casts where the readability benefit of a pattern-maching instanceof is clear, i.e. those within the then branch of an if and those inside the same expression, are still replaced.

The default of the option is true, which keeps the current behavior. It would also be possible to change this in order to only produce suggestions for the obvious cases by default.

Fixes #4925

This introduces a configuration option that allows one to disable
the replacement of casts that are implied by a negated instanceof
expression and are not within the same expression as the instanceof.
This affects casts in else branches and those below an if statement
where the then branch always returns from the method.
Casts where the readability benefit of a pattern-maching instanceof
is clear, i.e. those within the then branch of an if
and those inside the same expression, are still replaced.

The default of the option is true, which keeps the current behavior.

Fixes google#4925
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.

Feature request: Let PatternMatchingInstanceof apply only in same block
1 participant