Skip to content

Ambiguous signature for extracting() when using Kotlin #1499

@chrisly42

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.

Metadata

Metadata

Labels

event: Hack.Commit.PushA topic worked on during a Hack.Commit.Push eventlanguage: KotlinAn issue related to using AssertJ with Kotlin
No fields configured for 🐛 Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions