I've been using the new context parameter function...
# compiler
j
I've been using the new context parameter functionality a lot but noticed something that seems like a compiler bug to me. I keep getting
com.android.tools.r8.internal.Yf: Field name '$$context-FlowCollector#1' cannot be represented in dex format.
but only on the android target (makes sense since this appears related to dexing). I am guessing that at some point the
#
is being used for a param name which dex doesn't like. Simple reproducer in thread.
Copy code
fun beginTest() {
    context(
        FlowCollector<Throwable> { it.printStackTrace() },
        FlowCollector<SomeType> { }
    ) {
        CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
            test()
        }
    }
}


context(
    one: FlowCollector<Throwable>,
    two: FlowCollector<SomeType>
)
fun test() {
    println(one)
    println(two)
}

data object SomeType
Funny behavior. If I move the coroutine scope above all the context calls, it does compile:
Copy code
fun beginTest() {
    CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch {
        context(
            FlowCollector<Throwable> { it.printStackTrace() },
            FlowCollector<SomeType> { }
        ) {
            test()
        }
    }
}
d
Could you please report an issue?
j
Can do