1
votes

How can i reference the following function

@SinceKotlin("1.3")
public fun <T> sequence(@BuilderInference block: suspend SequenceScope<T>.() -> Unit): Sequence<T> = Sequence { iterator(block) }

Attempting

val sequenceFunction: KFunction<Sequence<Int>> = ::sequence

results in a compile-time error

Type inference failed: Not enough information to infer parameter T in fun sequence(block: suspend SequenceScope.() -> Unit): Sequence Please specify it explicitly.

1

1 Answers

1
votes
val f: (suspend SequenceScope<Int>.() -> Unit) -> Sequence<Int> = ::sequence

worked

Note: The obtained object is some sort of a wrapper function type. Not the actual function declaration. Running this can demonstrate that.