Christian Maus
06/28/2022, 5:49 PMprogram
, which is a contextual function can not be evaluated when the context parameter is brought into scope.
Should I file a bug report? 🤔
fun interface Context1 {
fun c1(): Int
}
fun interface Context2 {
fun c2(v: Int): String
}
context(Context1)
fun useC1(): context(Context2) (Int) -> String {
val x = c1()
return { c2(it + x) }
}
fun main(args: Array<String>) {
val program: context(Context2) (Int) -> String = with(Context1 { 42 }) {
useC1()
}
//this works
val result = program(Context2 { "the value is $it" }, 2)
//but this doesn't work
with(Context2 { "the value is $it" }) {
program(2)
}
}
dmitriy.novozhilov
06/28/2022, 6:00 PMChristian Maus
06/28/2022, 6:05 PMYoussef Shoaib [MOD]
06/28/2022, 7:57 PMdmitriy.novozhilov
06/28/2022, 9:09 PM