// WITH_RUNTIME class Itr : Iterator by ArrayList().iterator() class MItr : MutableIterator by ArrayList().iterator() class LItr : ListIterator by ArrayList().listIterator() class MLItr : MutableListIterator by ArrayList().listIterator() class It : Iterable by ArrayList() class MIt : MutableIterable by ArrayList() class C : Collection by ArrayList() class MC : MutableCollection by ArrayList() class L : List by ArrayList() class ML : MutableList by ArrayList() class S : Set by HashSet() class MS : MutableSet by HashSet() class M : Map by HashMap() class MM : MutableMap by HashMap() class ME : Map.Entry { override val key: String get() = throw UnsupportedOperationException() override val value: String get() = throw UnsupportedOperationException() } class MME : MutableMap.MutableEntry { override val key: String get() = throw UnsupportedOperationException() override val value: String get() = throw UnsupportedOperationException() override fun setValue(value: String): String = throw UnsupportedOperationException() } fun assert(condition: Boolean, message: () -> String) { if (!condition) throw AssertionError(message())} fun box(): String { val itr = Itr() as Any val mitr = MItr() assert(itr !is MutableIterator<*>) { "Itr should satisfy '!is MutableIterator'" } assert(mitr is MutableIterator<*>) { "MItr should satisfy 'is MutableIterator'" } val litr = LItr() as Any val mlitr = MLItr() assert(litr !is MutableIterator<*>) { "LItr should satisfy '!is MutableIterator'" } assert(litr !is MutableListIterator<*>) { "LItr should satisfy '!is MutableListIterator'" } assert(mlitr is MutableListIterator<*>) { "MLItr should satisfy 'is MutableListIterator'" } val it = It() as Any val mit = MIt() val arrayList = ArrayList() assert(it !is MutableIterable<*>) { "It should satisfy '!is MutableIterable'" } assert(mit is MutableIterable<*>) { "MIt should satisfy 'is MutableIterable'" } assert(arrayList is MutableIterable<*>) { "ArrayList should satisfy 'is MutableIterable'" } val coll = C() as Any val mcoll = MC() assert(coll !is MutableCollection<*>) { "C should satisfy '!is MutableCollection'" } assert(coll !is MutableIterable<*>) { "C should satisfy '!is MutableIterable'" } assert(mcoll is MutableCollection<*>) { "MC should satisfy 'is MutableCollection'" } assert(mcoll is MutableIterable<*>) { "MC should satisfy 'is MutableIterable'" } assert(arrayList is MutableCollection<*>) { "ArrayList should satisfy 'is MutableCollection'" } val list = L() as Any val mlist = ML() assert(list !is MutableList<*>) { "L should satisfy '!is MutableList'" } assert(list !is MutableCollection<*>) { "L should satisfy '!is MutableCollection'" } assert(list !is MutableIterable<*>) { "L should satisfy '!is MutableIterable'" } assert(mlist is MutableList<*>) { "ML should satisfy 'is MutableList'" } assert(mlist is MutableCollection<*>) { "ML should satisfy 'is MutableCollection'" } assert(mlist is MutableIterable<*>) { "ML should satisfy 'is MutableIterable'" } assert(arrayList is MutableList<*>) { "ArrayList should satisfy 'is MutableList'" } val set = S() as Any val mset = MS() val hashSet = HashSet() assert(set !is MutableSet<*>) { "S should satisfy '!is MutableSet'" } assert(set !is MutableCollection<*>) { "S should satisfy '!is MutableCollection'" } assert(set !is MutableIterable<*>) { "S should satisfy '!is MutableIterable'" } assert(mset is MutableSet<*>) { "MS should satisfy 'is MutableSet'" } assert(mset is MutableCollection<*>) { "MS should satisfy 'is MutableCollection'" } assert(mset is MutableIterable<*>) { "MS should satisfy 'is MutableIterable'" } assert(hashSet is MutableSet<*>) { "HashSet should satisfy 'is MutableSet'" } assert(hashSet is MutableCollection<*>) { "HashSet should satisfy 'is MutableCollection'" } assert(hashSet is MutableIterable<*>) { "HashSet should satisfy 'is MutableIterable'" } val map = M() as Any val mmap = MM() val hashMap = HashMap() assert(map !is MutableMap<*, *>) { "M should satisfy '!is MutableMap'" } assert(mmap is MutableMap<*, *>) { "MM should satisfy 'is MutableMap'"} assert(hashMap is MutableMap<*, *>) { "HashMap should satisfy 'is MutableMap'" } val entry = ME() as Any val mentry = MME() hashMap[""] = "" val hashMapEntry = hashMap.entries.first() assert(entry !is MutableMap.MutableEntry<*, *>) { "ME should satisfy '!is MutableMap.MutableEntry'"} assert(mentry is MutableMap.MutableEntry<*, *>) { "MME should satisfy 'is MutableMap.MutableEntry'"} assert(hashMapEntry is MutableMap.MutableEntry<*, *>) { "HashMap.Entry should satisfy 'is MutableMap.MutableEntry'"} assert((mlist as Any) !is MutableSet<*>) { "ML !is MutableSet" } assert((mlist as Any) !is MutableIterator<*>) { "ML !is MutableIterator" } return "OK" }