https://kotlinlang.org logo
#eap
Title
# eap
e

Exerosis

06/27/2022, 1:35 AM
Strange maybe error?
Copy code
val <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:
Copy code
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:
Copy code
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.
a

Alexey Belkov [JB]

06/27/2022, 9:20 AM
Can you please create an issue at https://youtrack.jetbrains.com/issues/KT with a minimal sample code attached?
e

Exerosis

07/02/2022, 11:48 AM
https://youtrack.jetbrains.com/issue/KT-53048/Possible-inconsistency-in-marking-calls-as-ambiguous When I boiled it down it doesn't appear to be related to context or definitely non nullable types my bad.
🙏 1
4 Views