Skip to content

Ambiguous signature for extracting() when using Kotlin #1499

Description

@chrisly42

Summary

When trying to use .extracting() with lambdas in kotlin, the call is ambigous and will not compile out-of-the-box. I think this is due to

extracting(ThrowingExtractor<? super ELEMENT, V, EXCEPTION> extractor)
and
extracting(Function<? super ELEMENT, V> extractor)

have the same effective signature because in kotlin, there are no checked exceptions (thank god).

Example

assertThat(highlights).hasSize(6).extracting(HighlightInfo::getText).doesNotContain("assertThat")
// nor does this work
assertThat(highlights).hasSize(6).extracting { it.text }.doesNotContain("assertThat")

I've got no idea on how to fix that in a backwards compatible manner other than to have a different method name for kotlin that won't clash or trying to add an extension that will cope with it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

event: Hack.Commit.PushA topic worked on during a Hack.Commit.Push eventlanguage: KotlinAn issue related to using AssertJ with Kotlin

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions