Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardKotlindispatch virtual vs staticSingle-choice MCQ

An extension function and a member function have the same name and signature on the same receiver. The snippet calls it through a base-typed reference. Which is invoked and what dispatch mechanism decides this?

open class A { open fun foo() = "member A" } class B : A() { override fun foo() = "member B" } fun A.foo() = "extension" fun main() { val a: A = B() println(a.foo()) }