Jody
05/28/2020, 10:52 AMreified
method and my Mockito is presumably choosing the wrong method for some reason. So when running my tests, Mockito either chooses the method I want to mock or chooses the reified
Kotlin method, which then turns into an Exception because the return types do not match. Did someone run into this problem already or know how to fix this?Jody
05/28/2020, 10:52 AMreified
method that gets chosen by Mockito is in line 254: https://github.com/tipsy/javalin/blob/be8910b3e867e1662663fbedb4e914c4262aff64/javalin/src/main/java/io/javalin/http/Context.kt#L246-L254Jody
05/28/2020, 10:53 AMSam Garfinkel
05/28/2020, 1:27 PMJody
05/28/2020, 1:28 PMSam Garfinkel
05/28/2020, 1:36 PMJody
05/28/2020, 1:41 PMContext.kt
class should be modified?Sam Garfinkel
05/28/2020, 1:48 PMSam Garfinkel
05/28/2020, 1:48 PMJody
05/28/2020, 2:20 PMtipsy
05/28/2020, 2:39 PMtipsy
05/28/2020, 2:44 PMthe functions in Context.kt should be refactored to eliminate ambiguity.
header("myheader")
and header<Int>("myheader"))
are good method names imo 🤔Sam Garfinkel
05/28/2020, 3:05 PMheader("myHeader", Any::class)
for whatever reason when you call when(context.header("myHeader"))
I don’t have mockito handy but the problem would be clear by looking at the generated bytecode.Sam Garfinkel
05/28/2020, 3:06 PMfoo
in the following val foo = context.header("myHeader")
? Does the compiler say type inference fails or does it assume String?
. If the latter, that seems like a somewhat crazy feature of the compiler.tipsy
05/28/2020, 3:40 PMString?
tipsy
05/28/2020, 3:42 PMSam Garfinkel
05/28/2020, 5:48 PMinline fun <reified T> header(value: String): Validator<T>
and fun header(value: String): String?
are both satisfied by the expression above.