Skip to content

Use more records.#5781

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_912116354
May 7, 2026
Merged

Use more records.#5781
copybara-service[bot] merged 1 commit into
masterfrom
test_912116354

Conversation

@copybara-service
Copy link
Copy Markdown
Contributor

Use more records.

I noticed an IntelliJ suggestion for this in one file in unknown commit, so I decided to turn it loose.

Notes:

  • If anything gets us in trouble here, I would expect it to be a performance regression or behavioral bug from suddenly having a value-based equals implementation.
    • Out of fear of that, I reverted a proposed change to ResultingStore in AbstractNullnessPropagationTransfer. But I don't have confidence that (a) that would have been a problem or (b) that nothing else in this CL will be a problem.
    • Gemini notices that, in RefactoringCollection, DelegatingDescriptionListener does end up in a HashMultimap, but it seems unlikely that we care about equality there. (Perhaps we should be using a ListMultimap there, anyway, including to preserve ordering (though we could also accomplish that with LinkedHashMultimap if we wanted to keep to SetMultimap).
  • IntelliJ was even ready to update documentation (Immutable.md and ImmutableEnumChecker.md), but I reverted that.)
  • I reverted the change to CompilerBasedAbstractTest, since that would created a record with an array member, upsetting ArrayRecordComponent, which wasn't completely trivial to fix.
  • I wonder if any sort of named class has been overkill in some cases here. Like, maybe RefasterSuppressionHelper would be just as well off with a static method that returns an instance of anonymous type? Maybe some of the matchers could be implemented with lambdas? I didn't get into that.
  • I'm still not entirely sure what to think of using record for classes that aren't what I think of as "value types," like DelegatingDescriptionListener in RefactoringCollection or the aforementioned matchers. Since most of the types here are implementation details, I don't worry about them as much as I worried in b/380275991, but I'm still personally not sure what to think.

I noticed an IntelliJ suggestion for this in one file in unknown commit, so I decided to turn it loose.

Notes:
- If anything gets us in trouble here, I would expect it to be a performance regression or behavioral bug from suddenly having a value-based `equals` implementation.
   - Out of fear of that, I reverted a proposed change to `ResultingStore` in `AbstractNullnessPropagationTransfer`. But I don't have confidence that (a) that would have been a problem or (b) that nothing else in this CL will be a problem.
   - Gemini notices that, in `RefactoringCollection`, `DelegatingDescriptionListener` does end up in a `HashMultimap`, but it seems unlikely that we care about equality there. (Perhaps we should be using a `ListMultimap` there, anyway, including to preserve ordering (though we could also accomplish that with `LinkedHashMultimap` if we wanted to keep to `SetMultimap`).
- IntelliJ was even ready to update documentation (`Immutable.md` and `ImmutableEnumChecker.md`), but I reverted that.)
- I reverted the change to `CompilerBasedAbstractTest`, since that would created a record with an array member, upsetting [ArrayRecordComponent](http://errorprone.info/bugpattern/ArrayRecordComponent), which wasn't completely trivial to fix.
- I wonder if any sort of named class has been overkill in some cases here. Like, maybe `RefasterSuppressionHelper` would be just as well off with a static method that returns an instance of anonymous type? Maybe some of the matchers could be implemented with lambdas? I didn't get into that.
- I'm still not entirely sure what to think of using `record` for classes that aren't what I think of as "value types," like `DelegatingDescriptionListener` in `RefactoringCollection` or the aforementioned matchers. Since most of the types here are implementation details, I don't worry about them as much as I worried in b/380275991, but I'm still personally not sure what to think.
PiperOrigin-RevId: 912209326
@copybara-service copybara-service Bot merged commit 6753f23 into master May 7, 2026
@copybara-service copybara-service Bot deleted the test_912116354 branch May 7, 2026 23:15
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