How can java.util.ArrayList inherit from MutableList

hi i try to understand some Konzepts about Kotlin.
when i was looking at the collections at kotlin.collections - Kotlin Programming Language

that ArrayList or HashMap have The JS Tag for the Javascript Plattform on it. Which I understand means its only used when targetting Javascript. In Intelij when I am doing a Java Project and add Kotlin support for JVM, I can still freely use kotlin.ArrayList. I saw that in TypeAlias.kt since Kotlin 1.1 their are stored follow Informations:

@file:kotlin.jvm.JvmVersion

package kotlin.collections

@SinceKotlin("1.1") public typealias RandomAccess = java.util.RandomAccess


@SinceKotlin("1.1") public typealias ArrayList<E> = java.util.ArrayList<E>
@SinceKotlin("1.1") public typealias LinkedHashMap<K, V> = java.util.LinkedHashMap<K, V>
@SinceKotlin("1.1") public typealias HashMap<K, V> = java.util.HashMap<K, V>
@SinceKotlin("1.1") public typealias LinkedHashSet<E> = java.util.LinkedHashSet<E>
@SinceKotlin("1.1") public typealias HashSet<E> = java.util.HashSet<E>


// also @SinceKotlin("1.1")
internal typealias SortedSet<E> = java.util.SortedSet<E>
internal typealias TreeSet<E> = java.util.TreeSet<E>

so kotlin.ArrayList is just an alias for the Java Version java.util.ArrayList.
java.utilArrayList extends AbstractList and implements List, RandomAccess, Cloneable, java.io.Serializable.

so its not implements MutableList. So how is it possible that the code:

var myList:MutableList<String>=ArrayList<String>()

works when ArrayList not implementing MutableList? A Soloution would be a Class extension, but as i Understand know you can only extends Funktions or Propertys.

1 Like

java.util.List is mapped to MutableList (or List depending on the type of the variable the list is assigned to): http://kotlinlang.org/docs/reference/java-interop.html#mapped-types