Can the Kotlin Compiler require non-null assertions?
for example. I'm getting a query result from JOOQ, and the relting type is Record!
. But the compiler allows me to access members without checking for null.
val orderResult = RowanDatabaseConnector.runInContext(DatabaseContext.BOOKSTORE) {
it.select(SPREE_ORDERS.asterisk())
.from(SPREE_ORDERS)
.where(SPREE_ORDERS.ID.eq(orderId.toInt()))
.fetchOne()
}
return Cart(
user = currentUser,
subTotal = orderResult.get(SPREE_ORDERS.ITEM_TOTAL).toFloat(),
taxTotal = orderResult.get(SPREE_ORDERS.ADDITIONAL_TAX_TOTAL).toFloat(),
total = orderResult.get(SPREE_ORDERS.TOTAL).toFloat(),
lineItems = listOf()
)
Is there something similar to Typescript's strictNullCheck
that would require that I assert that orderResult
is not null?