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

Non-nullability gets lost with shouldBeSuccess matcher #2759

Closed
Tracked by #2678
sschuberth opened this issue Jan 6, 2022 · 1 comment
Closed
Tracked by #2678

Non-nullability gets lost with shouldBeSuccess matcher #2759

sschuberth opened this issue Jan 6, 2022 · 1 comment
Milestone

Comments

@sschuberth
Copy link
Member

This looks like a bug to me:

fun <T> Result<T>.shouldBeSuccess(block: ((T?) -> Unit)? = null) {

If the result is of type T (non-nullable), why is the block then called with the nullable type T??

@sschuberth
Copy link
Member Author

shouldBeFailure has a similar problem:

fun Result<Any?>.shouldBeFailure(block: ((Throwable?) -> Unit)? = null) {
this should BeFailure()
block?.invoke(this.exceptionOrNull()!!)
}

The block is explicitly invoked with the not-null assertion operator (!!), but still the signature says Throwable?.

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 6, 2022
Use Kotlin built-in functionality wherever possible.

Note that there seems to be a nullability issue with Kotest's
`shouldBeSuccess` / `shouldBeFailure` matchers, see [1].

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 6, 2022
Use Kotlin built-in functionality wherever possible.

Note that there seems to be a nullability issue with Kotest's
`shouldBeSuccess` / `shouldBeFailure` matchers, see [1].

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 7, 2022
Use Kotlin built-in functionality wherever possible.

Note that there seems to be a nullability issue with Kotest's
`shouldBeSuccess` / `shouldBeFailure` matchers, see [1].

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit that referenced this issue Jan 10, 2022
Use exactly the same (not-null) type when calling the `block` as used in
the `Result`. Fixes #2759.
@sksamuel sksamuel modified the milestones: 5.0.4, 5.1 Jan 10, 2022
@sksamuel sksamuel mentioned this issue Jan 16, 2022
16 tasks
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1]. This allows for some simplifications as [2] was fixed.

[1]: https://kotest.io/docs/changelog.html#510-january-2022
[2]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1]. This allows for some simplifications as [2] was fixed.

[1]: https://kotest.io/docs/changelog.html#510-january-2022
[2]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1]. This allows for some simplifications as [2] was fixed.

[1]: https://kotest.io/docs/changelog.html#510-january-2022
[2]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1] which was fixed in Kotest 5.1.0.

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1] which was fixed in Kotest 5.1.0.

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1] which was fixed in Kotest 5.1.0.

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Jan 17, 2022
See [1] which was fixed in Kotest 5.1.0.

[1]: kotest/kotest#2759

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants