Skip to content

Kotlin bug Result unwrapping affects Atrium #1234

@robstoll

Description

@robstoll

Affected Version

0.18.0

API

fluent-en_GB, infix-en_GB

Platform

jvm

Kotlin Version

1.4

How to reproduce the problem?

expect(Result.failure<int>(IllegalArgumentException("oh no")).toBeAFailure()

=> is success

Describe the bug

See https://youtrack.jetbrains.com/issue/KT-50974 => fix is only provided in Kotlin 1.6.20

Expected behaviour

We want that people working with Kotlin 1.4.x and 1.5.x are not affected by this Kotlin bug.
Thus, we need to implement a workaround so that the user does not get in touch with this bug (at least when using Atrium).

We can do this by comparing container.maybeSubject with the (wrong) subject provided by Kotlin. In case they differ and it is a Result.isSuccess which contains another Result, then we unwrap it.

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions