Inspectopedia
 
2024.3

'inline fun' with nullable receiver until Kotlin 1.2

Warning
New
Last modified: 03 December 2024

Reports potentially unsafe calls of inline functions with flexible nullable (platform type with unknown nullability) extension receivers.

Before Kotlin 1.2, calls of inline fun with flexible nullable extension receiver (a platform type with an unknown nullability) did not include nullability checks in bytecode. Since Kotlin 1.2, nullability checks are included into the bytecode (see KT-12899).

It's recommended to add an explicit !! you want an exception to be thrown, or consider changing the function's receiver type to nullable if it should work without exceptions.

Example:

After the quick-fix is applied:

This inspection only reports if the Kotlin language level of the project or module is lower than 1.2.