Skip to content

Fixes #5553 : Skip UnnecessaryOptionalGet when lambda parameter is unnamed#5718

Open
copybara-service[bot] wants to merge 1 commit intomasterfrom
test_897687291
Open

Fixes #5553 : Skip UnnecessaryOptionalGet when lambda parameter is unnamed#5718
copybara-service[bot] wants to merge 1 commit intomasterfrom
test_897687291

Conversation

@copybara-service
Copy link
Copy Markdown
Contributor

Fixes #5553 : Skip UnnecessaryOptionalGet when lambda parameter is unnamed

UnnecessaryOptionalGet suggested replacing .get() with the lambda parameter name, but the parameter _ (unnamed variable, Java 22+) produces uncompilable code since _ cannot be referenced.

Changes:

  • Added an early return when the lambda parameter source is _
  • Added a test guarded by assume().that(Runtime.version().feature()).isAtLeast(22)

Fixes #5553

Fixes #5649

FUTURE_COPYBARA_INTEGRATE_REVIEW=#5649 from mirkoalicastro:mirkoalicastro/fix-unnecessary-optional-get-unnamed-variable bdcd042

…named

`UnnecessaryOptionalGet` suggested replacing `.get()` with the lambda parameter name, but the parameter `_` (unnamed variable, Java 22+) produces uncompilable code since `_` cannot be referenced.

Changes:
- Added an early return when the lambda parameter source is `_`
- Added a test guarded by `assume().that(Runtime.version().feature()).isAtLeast(22)`

Fixes #5553

Fixes #5649

FUTURE_COPYBARA_INTEGRATE_REVIEW=#5649 from mirkoalicastro:mirkoalicastro/fix-unnecessary-optional-get-unnamed-variable bdcd042
PiperOrigin-RevId: 897687291
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.

Improved suggestions when unnamed variables are used

1 participant