Andrey Navodnik
11/22/2023, 6:11 AMfun test() {
@Suppress("UNUSED_PARAMETER")
suspend fun f(value: Int) {} // Incorrect warning: Redundant 'suspend' modifier
val executors = mutableListOf<Pair<suspend (Int) -> Unit, Int>> ()
val executor = Pair(::f, 0)
executors.add(executor)
}
compiler shows, in my opinion, incorrect warning for function f(value: Int)
, and that is:
Redundant 'suspend' modifier
If the suspend
keyword is deleted, than the program does not compile anymore. The error message is:
Type mismatch.
Required:
Pair<suspend (Int) → Unit, Int>
Found:
Pair<KFunction1<Int, Unit>, Int>
Are my observations/conclusions correct? Any suggestions?
For your information, I'm using the following IntelliJ IDEA:
IntelliJ IDEA 2023.2.5 (Community Edition)
Build #IC-232.10227.8, built on November 9, 2023
Runtime version: 17.0.9+7-b1000.46 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 3072M
Cores: 8
Kotlin: 232-1.9.0-IJ10227.8
Kind regards, Andreydmitriy.novozhilov
11/22/2023, 8:13 AM@Suppress("RedundantSuspendModifier")
or disable globally with settings -> editor -> inspectionsAndrey Navodnik
11/22/2023, 8:59 AM