Exerosis
06/27/2022, 1:35 AMval <Key : Any, Value> Mutated<Key, Value>.onEach get(): (suspend Toggled.((suspend Toggled.(Key, Value & Any) -> (Unit))) -> (Unit))
val <Key : Any, Value> Mutable<Key, Value?>.onEach get(): (suspend Toggled.((suspend Togglable.(Key, Value & Any) -> (Unit))) -> (Unit))
If I have these two signatures it calls the top one on Mutated the bottom on Mutable and there is no ambiguity.
However if I have these two functions instead:
context(Toggled) @Keyword
suspend fun <Key : Any, Value> Mutable<Key, Value>.onEach(
block: suspend Togglable.(Key, Value & Any) -> (Unit)
)
context(Toggled) @Keyword
suspend fun <Key : Any, Value> Mutated<Key, Value>.onEach(
block: suspend Toggled.(Key, Value & Any) -> (Unit)
)
It cannot figure out which one to use.
The top one has the same syntax as a result of this function:
context(Toggled) @Keyword
suspend operator fun <Return, First>
(suspend (Toggled).(First) -> (Return))
.invoke(first: First)
= this(this@Toggled, first)
Which used to be a member function of Toggled that I used before context was added.Alexey Belkov [JB]
06/27/2022, 9:20 AMExerosis
07/02/2022, 11:48 AM