@@ -67,6 +67,7 @@ import kotlin.coroutines.intrinsics.*
67
67
* @param block the function body.
68
68
*/
69
69
@SinceKotlin(" 1.4" )
70
+ @ExperimentalStdlibApi
70
71
public class DeepRecursiveFunction <T , R >(
71
72
internal val block : suspend DeepRecursiveScope <T , R >.(T ) -> R
72
73
)
@@ -79,6 +80,7 @@ public class DeepRecursiveFunction<T, R>(
79
80
* [callRecursive][DeepRecursiveScope.callRecursive].
80
81
*/
81
82
@SinceKotlin(" 1.4" )
83
+ @ExperimentalStdlibApi
82
84
public operator fun <T , R > DeepRecursiveFunction <T , R >.invoke (value : T ): R =
83
85
DeepRecursiveScopeImpl <T , R >(block, value).runCallLoop()
84
86
@@ -91,6 +93,7 @@ public operator fun <T, R> DeepRecursiveFunction<T, R>.invoke(value: T): R =
91
93
*/
92
94
@RestrictsSuspension
93
95
@SinceKotlin(" 1.4" )
96
+ @ExperimentalStdlibApi
94
97
public sealed class DeepRecursiveScope <T , R > {
95
98
/* *
96
99
* Makes recursive call to this [DeepRecursiveFunction] function putting the call activation frame on the heap,
@@ -118,11 +121,13 @@ public sealed class DeepRecursiveScope<T, R> {
118
121
119
122
// ================== Implementation ==================
120
123
124
+ @ExperimentalStdlibApi
121
125
private typealias DeepRecursiveFunctionBlock = suspend DeepRecursiveScope <* , * >.(Any? ) -> Any?
122
126
123
127
private val UNDEFINED_RESULT = Result .success(COROUTINE_SUSPENDED )
124
128
125
129
@Suppress(" UNCHECKED_CAST" )
130
+ @ExperimentalStdlibApi
126
131
private class DeepRecursiveScopeImpl <T , R >(
127
132
block : suspend DeepRecursiveScope <T , R >.(T ) -> R ,
128
133
value : T
0 commit comments