Inspectopedia Help

'inline fun' with nullable receiver until Kotlin 1.2

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:

inline fun String.removePrefix(prefix: String): String { return this.substring(prefix.length) } fun main() { // `System.getProperty` returns not denotable `String!` type val property = System.getProperty("user.dir") println(property.removePrefix("/home")) }

After the quick-fix is applied:

inline fun String.removePrefix(prefix: String): String { return this.substring(prefix.length) } fun main() { // `System.getProperty` returns not denotable `String!` type val property = System.getProperty("user.dir") println(property!!.removePrefix("/home")) }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

PlatformExtensionReceiverOfInline
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Kotlin | Java interop issues

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

Inspection options

Here you can find the description of settings available for the 'inline fun' with nullable receiver until Kotlin 1.2 inspection, and the reference of their default values.

Pattern

(toBoolean)|(content.*)

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Kotlin, 241.18072-IJ

Last modified: 18 June 2024