Context receivers get technically compiled down to additional method arguments. Therefore from the compiler perspective the following has the same signature:
Copy code
fun test(x: Int)
context(Int)
fun test()
Would it make sense then to allow overriding a method via a context receiver? E.g.
Copy code
interface Test {
fun test(x: Int, y: String)
}
object : Test {
context(Int)
override fun test(y: String)
}
This would come handed when dealing with generated interfaces, so that some of the parameters in the implementation can be designated as contexts.
a
Alejandro Serrano.Mena
11/08/2024, 7:45 PM
unfortunately this would make resolution quite crazy; this is already forbidden even for regular receivers (you cannot override