I'm practicing with collections in Kotlin and cannot understand behavior of interfaces. Here is background of my question:
public interface List<out E> : Collection<E> {...}
public interface MutableList<E> : List<E>, MutableCollection<E> {...}
List and MutableList are interfaces defined in Kotlin, which is easy to understand. Now if I want to get an instance of a List these methods can be used: arrayListOf() or mutableListOf(). Both methods use the same typealias, which is actually links to the Java implementation of ArrayList.
public typealias ArrayList<E> = java.util.ArrayList<E>
Here a mysterious thing, MutableList doesn't have an implementation in Kotlin, so how Kotlin knows that java.util.ArrayList can be assigned to a MutableList variable? In other words, how Kotlin and Java interfaces are correlated to each other?