var result = "" public abstract class AbstractFoo : Map { override operator fun get(key: K): V? { result = "AbstractFoo" return null } override val size: Int get() = throw UnsupportedOperationException() override fun isEmpty(): Boolean { throw UnsupportedOperationException() } override fun containsKey(key: K): Boolean { throw UnsupportedOperationException() } override fun containsValue(value: V): Boolean { throw UnsupportedOperationException() } override val keys: Set get() = throw UnsupportedOperationException() override val values: Collection get() = throw UnsupportedOperationException() override val entries: Set> get() = throw UnsupportedOperationException() } public open class StringFoo : AbstractFoo() { override operator fun get(key: String): E? { result = "StringFoo" return null } } public class IntFoo : AbstractFoo() { override operator fun get(key: Int): E? { result = "IntFoo" return null } } public class AnyFoo : AbstractFoo() {} fun box(): String { StringFoo().get("") if (result != "StringFoo") return "fail 1: $result" IntFoo().get(1) if (result != "IntFoo") return "fail 2: $result" AnyFoo().get(null) if (result != "AbstractFoo") return "fail 3: $result" return "OK" }