[JVM IR] Support Suspend Main
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
This commit is contained in:
committed by
Ilmir Usmanov
parent
068d547375
commit
55aafb3430
@@ -0,0 +1,12 @@
|
||||
// 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
|
||||
Reference in New Issue
Block a user