Skip to content
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

Optionally recommend against static import of Truth8.assertThat. #4264

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

Optionally recommend against static import of Truth8.assertThat.

The methods there will be moving into the main Truth class. Users will have various options for how to migrate, but one option involves avoiding static imports. We will provide more instructions as part of our Truth releases. (See, e.g., the release notes for Truth 1.3.0.)

Rough outline of the option that involves avoiding static imports:

  • The problem with adding Truth8.assertThat(OptionalInt) (or a similar overload) to Truth is that anyone who static imports both Truth.assertThat and Truth8.assertThat will see ambiguity errors if they use that method.
  • The solution is to stop using static import for Truth8.assertThat. Once all its static imports are gone, we can add the new methods to Truth without breaking anyone, and then we can migrate users.
  • Avoiding static import for Truth8.assertThat would be tough to swallow for the most common types, Stream and Optional. Luckily, I found an alternative approach that works for those, as discussed in the linked release notes. (That approach works for those types because they're generic types.)

@copybara-service copybara-service bot closed this Jan 26, 2024
@copybara-service copybara-service bot deleted the test_601232868 branch January 26, 2024 22:11
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.

0 participants