Overview - Extensions resolved statically
What is it?
Extensions resolved statically is a Kotlin feature where extension functions are called based on the declared type of the variable, not the actual object type at runtime. This means that even if an object is of a subclass, the extension function of the declared type is used. Extensions let you add new functions to existing classes without changing their code.
Why it matters
This concept exists to clarify how Kotlin handles extension functions, avoiding confusion about which function runs. Without this, developers might expect extensions to behave like normal overridden methods, causing bugs and unexpected behavior. Understanding this helps write safer and more predictable code when using extensions.
Where it fits
Before learning this, you should know about Kotlin classes, inheritance, and basic extension functions. After this, you can explore advanced Kotlin features like member extensions, inline classes, and polymorphism nuances.