Inspectopedia Help

Progression resolution change since 1.9

Reports overloaded function calls where an argument requires an explicit cast to resolve to a proper declaration. The current compiler warning (available since Kotlin 1.6.20) will become an error in Kotlin 1.8.

Progressions and ranges types (kotlin.ranges) will start implementing the Collection interface in Kotlin 1.9 and later. This update will cause a change in resolution for overloaded functions. For instance, in the example below, the test(1..5) call will be resolved to test(t: Any) in Kotlin 1.8 and earlier and to test(t: Collection<*>) in Kotlin 1.9 and later.

fun test(t: Any) { } fun test(t: Collection<*>) { } fun invoke() { test(1..5) // IntRange becomes Collection in 1.9 }

The provided quick-fix captures the behaviour specific to the compiler of version 1.8 and earlier:

fun test(t: Any) { } fun test(t: Collection<*>) { } fun invoke() { test(1..5) // resolved to 'test(t: T)' before Kotlin 1.9 }
fun test(t: Any) { } fun test(t: Collection<*>) { } fun invoke() { test((1..5) as Iterable<Int>) // resolved to 'test(t: T)' in Kotlin 1.9 }

Inspection is available for the Kotlin language level starting from 1.6.

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Kotlin, 241.14841-IJ

Last modified: 12 March 2024