Added trampoline for coroutine suspend argument access
This commit is contained in:
parent
94e835218a
commit
a52c2d9adb
24
src/dorkbox/network/other/SuspendFunctionAccess.java
Normal file
24
src/dorkbox/network/other/SuspendFunctionAccess.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package dorkbox.network.other;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import kotlin.coroutines.Continuation;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* Class to access suspending invocation of methods from kotlin...
|
||||
*
|
||||
* ULTIMATELY, this is all java bytecode, and the bytecode signature here matches what kotlin expects. The generics type information is
|
||||
* discarded at compile time.
|
||||
*/
|
||||
public
|
||||
class SuspendFunctionAccess {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static
|
||||
Object invokeSuspendFunction(@NotNull final Object suspendFunction, @NotNull final Continuation<?> continuation) {
|
||||
Function1<? super Continuation<? super Object>, ?> suspendFunction1 = (Function1<? super Continuation<? super Object>, ?>) suspendFunction;
|
||||
return suspendFunction1.invoke((Continuation<? super Object>) continuation);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user