https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
a

Andrey Navodnik

11/22/2023, 6:11 AM
Hi everybody, I would like to report a minor problem with Kotlin 2.0.0-beta1. If the following program is copied into editor
Copy code
fun 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:
Copy code
Redundant 'suspend' modifier
If the
suspend
keyword is deleted, than the program does not compile anymore. The error message is:
Copy code
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:
Copy code
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, Andrey
d

dmitriy.novozhilov

11/22/2023, 8:13 AM
Hey It's not the compiler warning but an IDE inspection Please create a YT ticket You can suppress it locally with
@Suppress("RedundantSuspendModifier")
or disable globally with settings -> editor -> inspections
a

Andrey Navodnik

11/22/2023, 8:59 AM
Dmitriy, thank for your answer. As you have suggested, I have created a ticket https://youtrack.jetbrains.com/issue/KTIJ-27905/Incorrect-warning-Redundant-suspend-modifier
👍 3