Inspectopedia
 
2024.3

'inline fun' extension receiver can be explicitly nullable until Kotlin 1.2

Info
New
Last modified: 03 December 2024

Reports inline functions with non-nullable extension receivers which don't use the fact that extension receiver is not nullable.

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).

Thus functions which do not use the fact that extension receiver is not nullable are dangerous in Kotlin until 1.2 and it's recommended to make such functions to have nullable receiver.

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.