Skip to content

extracting(Function...) propagates Object instead of the common base type of all extractors #3372

@xenoterracide

Description

@xenoterracide

Feature summary

So, I'm noticing that my attempts to validate that this toString() and getVersion are returning the same thing is kind of painful.

Example

// using semver4j, note this won't pass because my code subclasses and stuff even then, but compiling


      var v010 = Semver.coerce("v0.1.0");

     // asserthat(v010).matchesToString(...) nope doesn't exist

      assertThat(v010)
        .extracting(Semver::getVersion, Semver::toString)
        .allSatisfy(o -> {
          assertThat(o).isInstanceOf(String.class); // I guess chaining off this assertion won't convince allowance of matches
          if (o instanceof String s) { // but couldn't o already have determined we're a string?
            assertThat(s).matches("^0\\.1\\.0-SNAPSHOT-1-g\\p{XDigit}{7}$");
          }
        });

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions