phldavies
09/03/2025, 10:15 PMcontext(@Receiver _: MyScope) fun doSomething() { callSomething() }
be translated to
context(_: MyScope) fun doSomething { with(contextOf<MyScope>()) { callSomething() } }
My gut says no but this would be a nice way of avoiding the need to create context parameter bridge functions.Youssef Shoaib [MOD]
09/03/2025, 11:18 PMcontext(@Receiver _: MyScope) fun doSomething() {
with<MyScope>()
callSomething()
}
Using FirExpressionResolutionExtensionphldavies
10/17/2025, 11:56 AMwither @Youssef Shoaib [MOD] 😉Youssef Shoaib [MOD]
10/17/2025, 12:00 PMwith call based on @Receiver, and then wither takes care of adding it as a receiverphldavies
10/17/2025, 12:02 PMwith call for any context with a specific annotated type (to avoid bridging methods)
I.e.
@ContextAsReceiver // the annotation
interface Raise { fun raise(value: Any): Nothing }
context(_: Raise) fun doSomething { raise("hello") }Youssef Shoaib [MOD]
10/17/2025, 12:05 PMcontext(_: Raise) fun doSomething() = raise("hello")
But I can make this work:
context(_: Raise) fun doSomething(): Nothing = raise("hello")phldavies
10/17/2025, 12:06 PMNothing explicitly, but I get what you mean 🙂