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

Can't call "fail" in Kotlin without specifying generic type explicitly #1209

Closed
1 task
JLLeitschuh opened this issue Dec 15, 2017 · 0 comments
Closed
1 task

Comments

@JLLeitschuh
Copy link
Contributor

Overview

In java you can call fail like this:

fail("some message");

Because of how the Kotlin compiler works, the same call in kotlin becomes:

fail<Nothing>("some message")

Trying to just have:

fail("some message")

Causes the compiler to spit out the following error:

Error:(155, 9) Kotlin: Type inference failed: Not enough information to infer parameter V in fun <V : Any!> fail(p0: String!): V!
Please specify it explicitly.

Proposed Solution

Add to the existing Assertions.kt file something like the following:

fun fail(message: String) = org.junit.jupiter.api.Assertions.fail<Nothing>(message)

Similar overloads will have to be provided for the other various fail overloads.

Deliverables

  • Addition of the fail api to the Assertions.kt file.
JLLeitschuh added a commit to JLLeitschuh/junit5 that referenced this issue Dec 20, 2017
Andrei94 pushed a commit to Andrei94/junit5 that referenced this issue Jun 23, 2018
Add Kotlin "fail" methods to org.junit.jupiter.api

Closes junit-team#1209
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

1 participant