Support parameterless and suspend main functions in multifile classes
#KT-26574 Fixed
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Foo")
|
||||
package Hello
|
||||
|
||||
suspend fun main(args: Array<String>) {}
|
||||
@@ -0,0 +1,18 @@
|
||||
@kotlin.Metadata
|
||||
public final class Hello/Foo {
|
||||
public final static @org.jetbrains.annotations.Nullable method main(@org.jetbrains.annotations.NotNull p0: java.lang.String[], @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic static method main(p0: java.lang.String[]): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class Hello/Foo__MultifileSuspendKt$$$main {
|
||||
private final field args: java.lang.String[]
|
||||
synthetic method <init>(p0: java.lang.String[]): void
|
||||
public synthetic final method invoke(p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
synthetic final class Hello/Foo__MultifileSuspendKt {
|
||||
public final static @org.jetbrains.annotations.Nullable method main(@org.jetbrains.annotations.NotNull p0: java.lang.String[], @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
|
||||
public synthetic static method main(p0: java.lang.String[]): void
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,37 @@
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Foo")
|
||||
package Hello
|
||||
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
@kotlin.jvm.Volatile
|
||||
private var result = ""
|
||||
@kotlin.jvm.Volatile
|
||||
private var callback: Function0<Unit>? = null
|
||||
|
||||
suspend fun appendAndSuspend(s: String) {
|
||||
result += s
|
||||
|
||||
suspendCoroutine<Unit> { continuation ->
|
||||
callback = {
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
thread(isDaemon = true) {
|
||||
while (true) {
|
||||
val c = callback
|
||||
c?.invoke()
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
appendAndSuspend(args[0])
|
||||
appendAndSuspend(args[1])
|
||||
println(result)
|
||||
callback = null
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
Reference in New Issue
Block a user