Compound extension

And is there a rule that explain this code :


open class A
class A1 : A()

open class B
class B1 : A()

fun test(a: A, b : B) {    print("A - B") }

fun test(a: A, b : B1)  {   print("A - B1") }

fun test(a: A1, b : B) {  print("A1 - B") }

fun main() {
    val a = A1()
    val b = B1()
    test(a, b)
}

print “A - B1” and not “A1 - B”