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

Ambiguous assertThat for Temporal instance implementing Comparable #3491

Closed
armandino opened this issue May 27, 2024 · 3 comments · Fixed by #3519
Closed

Ambiguous assertThat for Temporal instance implementing Comparable #3491

armandino opened this issue May 27, 2024 · 3 comments · Fixed by #3519
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@armandino
Copy link
Contributor

Describe the bug

The upgrade to 3.26.0 results in a compilation error when invoking assertThat() with an argument of type java.time.Year.

  • assertj core version: 3.26.0
  • java version: 17

Test case reproducing the bug

@Test
void example() {
    Year year = Year.now();
    assertThat(year).isNotNull();
}

image

@scordio
Copy link
Member

scordio commented May 27, 2024

Thanks for reporting it, @armandino!

@scordio scordio added the type: regression A regression from a previous release label May 27, 2024
@scordio scordio added this to the 3.26.1 milestone May 27, 2024
@scordio
Copy link
Member

scordio commented May 27, 2024

In case of Year instances, we have a clash between assertThat(Temporal) (added with 46630d7) and assertThat(Comparable).

@scordio scordio self-assigned this May 27, 2024
@scordio
Copy link
Member

scordio commented May 27, 2024

Unfortunately, this happens whenever actual implements both Comparable and another interface (e.g., Temporal), and AssertJ offers separate assertThat methods for both Comparable and the interface instances. In such cases, the compiler cannot identify the proper assertThat candidate.

A way forward could be reverting the assertThat(Temporal) introduced with 46630d7 and introducing assertThatTemporal to satisfy @xenoterracide's request at #3404, similar to what we did in 17a5216.

@scordio scordio changed the title Ambiguous method call: Year and Temporal Ambiguous assertThat method call for Temporal instances implementing Comparable May 28, 2024
@scordio scordio changed the title Ambiguous assertThat method call for Temporal instances implementing Comparable Ambiguous assertThat method call for Temporal instance implementing Comparable May 28, 2024
@scordio scordio changed the title Ambiguous assertThat method call for Temporal instance implementing Comparable Ambiguous assertThat for Temporal instance implementing Comparable May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants