55aafb3430
This adds supports for (parameterless) suspend main entry points for
the JVM IR backend.
In case main is a suspend function, it gains a continuation during
lowering, so we simply generate a plain old `public static void
main(String[] args)`. This entry point invokes `suspend main` via
`kotlin.coroutines.jvm.internal.RunSuspendKt#runSuspend`.
This PR introduces `runSuspend` as a built-in, and generates the
following `main`, passing `args` as appropriate:
```
fun main(args: Array<String>) {
runSuspend { main(args) }
}
```
The phase ordering has been reshuffled countrary to previous
discussion on #2780, as the MainMethodGeneration pass now introduces lambdas in
the IR. Hence, it has to run before InventNamesForLocalClasses, yet
still after JvmOverloadsAnnotations.
Some dead code was discovered in AddContinuationLowering
12 lines
367 B
Kotlin
Vendored
12 lines
367 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
suspend fun main() {
|
|
|
|
}
|
|
|
|
// method: ParameterlessSuspendMainKt::main
|
|
// jvm signature: (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
|
// generic signature: (Lkotlin/coroutines/Continuation<-Lkotlin/Unit;>;)Ljava/lang/Object;
|
|
|
|
// method: ParameterlessSuspendMainKt::main
|
|
// jvm signature: ([Ljava/lang/String;)V
|
|
// generic signature: null |