cf425ffded
Fix some unresolved supertypes. This is necessary to be able to enable IR fake override builder by default (KT-61514), because it traverses all supertypes and asserts that they're classes, so that it can build fake overrides for declarations from there. Without this change, for example `IrFakeOverrideBuilder.buildFakeOverridesForClass` would crash.
42 lines
1.5 KiB
Kotlin
Vendored
42 lines
1.5 KiB
Kotlin
Vendored
@file:kotlin.jvm.JvmMultifileClass
|
|
@file:kotlin.jvm.JvmName("SetsKt")
|
|
|
|
package kotlin.collections
|
|
|
|
internal object EmptySet : Set<Nothing>, java.io.Serializable {
|
|
private const val serialVersionUID: Long = 3406603774387020532
|
|
|
|
override fun equals(other: Any?): Boolean = other is Set<*> && other.isEmpty()
|
|
override fun hashCode(): Int = 0
|
|
override fun toString(): String = "[]"
|
|
|
|
override val size: Int get() = 0
|
|
override fun isEmpty(): Boolean = true
|
|
override fun contains(element: Nothing): Boolean = false
|
|
override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()
|
|
|
|
override fun iterator(): Iterator<Nothing> = EmptyIterator
|
|
|
|
private fun readResolve(): Any = EmptySet
|
|
}
|
|
|
|
public fun <T> emptySet(): Set<T> = EmptySet
|
|
|
|
public fun <T> setOf(vararg elements: T): Set<T> = if (elements.size > 0) elements.toSet() else emptySet()
|
|
|
|
public inline fun <T> setOf(): Set<T> = emptySet()
|
|
|
|
public inline fun <T> mutableSetOf(): MutableSet<T> = LinkedHashSet()
|
|
|
|
public fun <T> mutableSetOf(vararg elements: T): MutableSet<T> = elements.toCollection(LinkedHashSet(mapCapacity(elements.size)))
|
|
|
|
public inline fun <T> hashSetOf(): HashSet<T> = kotlin.UnsupportedOperationException("This is intrinsic")
|
|
|
|
public fun <T> hashSetOf(vararg elements: T): HashSet<T> = kotlin.UnsupportedOperationException("This is intrinsic")
|
|
|
|
internal fun <T> Set<T>.optimizeReadOnlySet() = when (size) {
|
|
0 -> emptySet()
|
|
1 -> setOf(iterator().next())
|
|
else -> this
|
|
}
|