Joffrey
08/12/2022, 2:55 PMfun <C1, C2, R> withBoth(c1: C1, c2: C2, block: context(C1, C2) () -> R): R = block(c1, c2)
And I get this compiler error:
Subtyping relation between context receivers is prohibited
Is this a bug, or did I mess up the syntax somewhere? There is no subtyping intended anywhere here.
Note that moving C2
as a regular receiver fixes the compilation:
fun <C1, C2, R> withBoth(c1: C1, c2: C2, block: context(C1) C2.() -> R): R = block(c1, c2)
Joffrey
08/12/2022, 3:01 PMwithBoth
(defined with 2 context receivers) with a lambda (in 1.7.10). It works fine when passing a method reference as the block
. Since it is pretty similar to https://youtrack.jetbrains.com/issue/KT-51243, and that one is supposedly fixed in 1.7.20, I wanted to try my luck with 1.7.20-Beta to see if it worked fine.Youssef Shoaib [MOD]
08/12/2022, 9:21 PMBalazs Toth
05/22/2023, 11:13 AMYoussef Shoaib [MOD]
05/22/2023, 12:03 PM@Suppress("SUBTYPING_BETWEEN_CONTEXT_RECEIVERS")
Balazs Toth
05/22/2023, 12:09 PM