Klitos Kyriacou
03/03/2022, 5:51 PMResultSet
, and therefore its getLong()
method returns a JVM platform type (i.e. it could be Long
or Long?
):
val id: Long? = <...>
every { resultSet.getLong("id") } returns id
Unfortunately, this results in the error message "Type mismatch: inferred type is Long? but Long was expected." Is this a bug, a known limitation, or something I'm doing wrong? I can work around it like this:
every { resultSet.getLong("id") as Long? } returns id
but then IntelliJ IDEA warns me that as Long?
is unnecessary.Sam
03/03/2022, 6:01 PMgetLong
returns a primitive long
, so it can never be null. Your id is defined as Long?
, which is nullable, so it can't be used as a return value for getLong
.Klitos Kyriacou
03/03/2022, 6:09 PM