ktfmt
ktfmt copied to clipboard
Cannot handle formatting `context` keyword
When using context for context receivers, the formatter throws the following error:
error: expected token: 'context'; generated ( instead
The code it highlights for the error is:
val viewEffectMap: MutableMap<KClass<out ViewEffect>, context(Context, View) (effect: ViewEffect) -> Unit> = mutableMapOf()
This breaks usage of using this context receiver feature with formatting.
I am seeing this with
public interface A<T> {
// ...
@SomeAnnotation
public infix fun someFun(block: context(SomeScope<T>) T.() -> Unit): T = invoke(block)
}
@bddckr, do you plan to maintain the context receivers/params integration next year?
@JavierSegoviaCordoba Sorry for the late reply.
My team continues using ktfmt and context receivers, so I will keep the minimum working. I know there will likely be a few changes to stay current with the Kotlin changes.
However, I'm stretched a bit thin for at least the next half a year. Therefore, I may not get around to anything but the bare minimum. Someone else may be interested in getting more done - more test scenarios and more features should be covered in ktfmt eventually for context receivers/parameters.
Fixed by https://github.com/facebook/ktfmt/commit/dafd1cbb34a049fd8606213f16ea63569f8e3d05