https://kotlinlang.org logo
#getting-started
Title
# getting-started
n

Norbi

12/14/2023, 10:54 AM
Currently something similar to this code
Copy code
interface A {
    val a: Any
}

interface B: A {
    context(C) // <--- an additional context of C is added to the overridden property
    override val a: Any
}
does not compile with an
Copy code
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
compiler crash. My question is, will it be supported in the future? (I'm not an expert but with the additional
context
it seems not to be an 'override' anymore...)
s

Sam

12/14/2023, 11:08 AM
I think your intuition is correct. The context receiver is effectively a parameter, so adding a new one would change the signature. It's implied in the KEEP also:
If a function or a property accessor is a member of some class or interface and has context receivers, then its overrides must have context receivers of the same types.
1
🙏 1
2 Views