Compare commits

...

3 Commits

Author SHA1 Message Date
Anton Bannykh
08527fdaa4 Tests updated 2017-11-01 15:56:29 +03:00
Anton Bannykh
e330dee39c enable commented out tests 2017-11-01 15:40:24 +03:00
Anton Bannykh
cd434a7d13 multiplatform hashmap (unfinished) 2017-10-30 16:08:12 +03:00
1211 changed files with 1998 additions and 1688 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,117 +13,674 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Based on GWT AbstractHashMap
* Copyright 2008 Google Inc.
*/
package kotlin.collections
import kotlin.collections.Map.Entry
import kotlin.collections.MutableMap.MutableEntry
class HashMap<K, V> private constructor(
private var keysArray: Array<K>,
private var valuesArray: Array<V>?, // allocated only when actually used, always null in pure HashSet
private var presenceArray: IntArray,
private var hashArray: IntArray,
private var maxProbeDistance: Int,
private var length: Int
) : MutableMap<K, V>, AbstractMutableMap<K, V>() {
private var hashShift: Int = computeShift(hashSize)
/**
* Hash table based implementation of the [MutableMap] interface.
*
* This implementation makes no guarantees regarding the order of enumeration of [keys], [elements] and [entries] collections.
*/
public open class HashMap<K, V> : AbstractMutableMap<K, V> {
override var size: Int = 0
private set
private inner class EntrySet : AbstractMutableSet<MutableEntry<K, V>>() {
private var keysView: HashSet<K>? = null
private var valuesView: HashMapValues<V>? = null
private var entriesView: HashMapEntrySet<K, V>? = null
override fun add(element: MutableEntry<K, V>): Boolean = throw UnsupportedOperationException("Add is not supported on entries")
override fun clear() {
this@HashMap.clear()
// ---------------------------- functions ----------------------------
constructor() : this(INITIAL_CAPACITY)
constructor(capacity: Int, loadFactor: Float = 0.0f) : this(
arrayOfUninitializedElements(capacity),
null,
IntArray(capacity),
IntArray(computeHashSize(capacity)),
INITIAL_MAX_PROBE_DISTANCE,
0)
constructor(m: Map<out K, V>) : this(m.size) {
putAll(m)
}
override fun isEmpty(): Boolean = size == 0
override fun containsKey(key: K): Boolean = findKey(key) >= 0
override fun containsValue(value: V): Boolean = findValue(value) >= 0
operator fun set(key: K, value: V): Unit {
put(key, value)
}
override operator fun get(key: K): V? {
val index = findKey(key)
if (index < 0) return null
return valuesArray!![index]
}
override fun put(key: K, value: V): V? {
val index = addKey(key)
val valuesArray = allocateValuesArray()
if (index < 0) {
val oldValue = valuesArray[-index - 1]
valuesArray[-index - 1] = value
return oldValue
} else {
valuesArray[index] = value
return null
}
override operator fun contains(element: MutableEntry<K, V>): Boolean = containsEntry(element)
override operator fun iterator(): MutableIterator<MutableEntry<K, V>> = internalMap.iterator()
override fun remove(element: MutableEntry<K, V>): Boolean {
if (contains(element)) {
this@HashMap.remove(element.key)
return true
}
return false
}
override val size: Int get() = this@HashMap.size
}
/**
* Internal implementation of the map: either string-based or hashcode-based.
*/
private val internalMap: InternalMap<K, V>
private val equality: EqualityComparator
internal constructor(internalMap: InternalMap<K, V>) : super() {
this.internalMap = internalMap
this.equality = internalMap.equality
override fun putAll(from: Map<out K, V>) {
putAllEntries(from.entries)
}
/**
* Constructs an empty [HashMap] instance.
*/
constructor() : this(InternalHashCodeMap(EqualityComparator.HashCode))
/**
* Constructs an empty [HashMap] instance.
*
* @param initialCapacity the initial capacity (ignored)
* @param loadFactor the load factor (ignored)
*
* @throws IllegalArgumentException if the initial capacity or load factor are negative
*/
constructor(initialCapacity: Int, loadFactor: Float = 0f) : this() {
// This implementation of HashMap has no need of load factors or capacities.
require(initialCapacity >= 0) { "Negative initial capacity" }
require(loadFactor >= 0) { "Non-positive load factor" }
}
/**
* Constructs an instance of [HashMap] filled with the contents of the specified [original] map.
*/
constructor(original: Map<out K, V>) : this() {
this.putAll(original)
override fun remove(key: K): V? {
val index = removeKey(key)
if (index < 0) return null
val valuesArray = valuesArray!!
val oldValue = valuesArray[index]
valuesArray.resetAt(index)
return oldValue
}
override fun clear() {
internalMap.clear()
// structureChanged(this)
}
override fun containsKey(key: K): Boolean = internalMap.contains(key)
override fun containsValue(value: V): Boolean = internalMap.any { equality.equals(it.value, value) }
private var _entries: MutableSet<MutableMap.MutableEntry<K, V>>? = null
override val entries: MutableSet<MutableMap.MutableEntry<K, V>> get() {
if (_entries == null) {
_entries = createEntrySet()
// O(length) implementation for hashArray cleanup
for (i in 0..length - 1) {
val hash = presenceArray[i]
if (hash >= 0) {
hashArray[hash] = 0
presenceArray[i] = TOMBSTONE
}
}
return _entries!!
keysArray.resetRange(0, length)
valuesArray?.resetRange(0, length)
size = 0
length = 0
}
protected open fun createEntrySet(): MutableSet<MutableMap.MutableEntry<K, V>> = EntrySet()
override val keys: MutableSet<K> get() {
val cur = keysView
return if (cur == null) {
val new = HashSet(this)
keysView = new
new
} else cur
}
override operator fun get(key: K): V? = internalMap.get(key)
override val values: MutableCollection<V> get() {
val cur = valuesView
return if (cur == null) {
val new = HashMapValues(this)
valuesView = new
new
} else cur
}
override fun put(key: K, value: V): V? = internalMap.put(key, value)
override val entries: MutableSet<MutableMap.MutableEntry<K, V>> get() {
val cur = entriesView
return if (cur == null) {
val new = HashMapEntrySet(this)
entriesView = new
return new
} else cur
}
override fun remove(key: K): V? = internalMap.remove(key)
override fun equals(other: Any?): Boolean {
return other === this ||
(other is Map<*, *>) &&
contentEquals(other)
}
override val size: Int get() = internalMap.size
override fun hashCode(): Int {
var result = 0
val it = entriesIterator()
while (it.hasNext()) {
result += it.nextHashCode()
}
return result
}
override fun toString(): String {
val sb = StringBuilder(2 + size * 3)
sb.append("{")
var i = 0
val it = entriesIterator()
while (it.hasNext()) {
if (i > 0) sb.append(", ")
it.nextAppendString(sb)
i++
}
sb.append("}")
return sb.toString()
}
// ---------------------------- private ----------------------------
private val capacity: Int get() = keysArray.size
private val hashSize: Int get() = hashArray.size
private fun ensureExtraCapacity(n: Int) {
ensureCapacity(length + n)
}
private fun ensureCapacity(capacity: Int) {
if (capacity > this.capacity) {
var newSize = this.capacity * 3 / 2
if (capacity > newSize) newSize = capacity
keysArray = keysArray.copyOfUninitializedElements(newSize)
valuesArray = valuesArray?.copyOfUninitializedElements(newSize)
presenceArray = presenceArray.copyOfUninitializedElements(newSize)
val newHashSize = computeHashSize(newSize)
if (newHashSize > hashSize) rehash(newHashSize)
} else if (length + capacity - size > this.capacity) {
rehash(hashSize)
}
}
private fun allocateValuesArray(): Array<V> {
val curValuesArray = valuesArray
if (curValuesArray != null) return curValuesArray
val newValuesArray = arrayOfUninitializedElements<V>(capacity)
valuesArray = newValuesArray
return newValuesArray
}
private fun hash(key: K) = (key.hashCode() * MAGIC) ushr hashShift
private fun compact() {
var i = 0
var j = 0
val valuesArray = valuesArray
while (i < length) {
if (presenceArray[i] >= 0) {
keysArray[j] = keysArray[i]
if (valuesArray != null) valuesArray[j] = valuesArray[i]
j++
}
i++
}
keysArray.resetRange(j, length)
valuesArray?.resetRange(j, length)
length = j
//check(length == size) { "Internal invariant violated during compact: length=$length != size=$size" }
}
private fun rehash(newHashSize: Int) {
if (length > size) compact()
if (newHashSize != hashSize) {
hashArray = IntArray(newHashSize)
hashShift = computeShift(newHashSize)
} else {
hashArray.fill(0, 0, hashSize)
}
var i = 0
while (i < length) {
if (!putRehash(i++)) {
throw IllegalStateException("This cannot happen with fixed magic multiplier and grow-only hash array. " +
"Have object hashCodes changed?")
}
}
}
private fun putRehash(i: Int): Boolean {
var hash = hash(keysArray[i])
var probesLeft = maxProbeDistance
while (true) {
val index = hashArray[hash]
if (index == 0) {
hashArray[hash] = i + 1
presenceArray[i] = hash
return true
}
if (--probesLeft < 0) return false
if (hash-- == 0) hash = hashSize - 1
}
}
private fun findKey(key: K): Int {
var hash = hash(key)
var probesLeft = maxProbeDistance
while (true) {
val index = hashArray[hash]
if (index == 0) return TOMBSTONE
if (index > 0 && keysArray[index - 1] == key) return index - 1
if (--probesLeft < 0) return TOMBSTONE
if (hash-- == 0) hash = hashSize - 1
}
}
private fun findValue(value: V): Int {
var i = length
while (--i >= 0) {
if (presenceArray[i] >= 0 && valuesArray!![i] == value)
return i
}
return TOMBSTONE
}
internal fun addKey(key: K): Int {
retry@ while (true) {
var hash = hash(key)
// put is allowed to grow maxProbeDistance with some limits (resize hash on reaching limits)
val tentativeMaxProbeDistance = (maxProbeDistance * 2).coerceAtMost(hashSize / 2)
var probeDistance = 0
while (true) {
val index = hashArray[hash]
if (index <= 0) { // claim or reuse hash slot
if (length >= capacity) {
ensureExtraCapacity(1)
continue@retry
}
val putIndex = length++
keysArray[putIndex] = key
presenceArray[putIndex] = hash
hashArray[hash] = putIndex + 1
size++
if (probeDistance > maxProbeDistance) maxProbeDistance = probeDistance
return putIndex
}
if (keysArray[index - 1] == key) {
return -index
}
if (++probeDistance > tentativeMaxProbeDistance) {
rehash(hashSize * 2) // cannot find room even with extra "tentativeMaxProbeDistance" -- grow hash
continue@retry
}
if (hash-- == 0) hash = hashSize - 1
}
}
}
internal fun removeKey(key: K): Int {
val index = findKey(key)
if (index < 0) return TOMBSTONE
removeKeyAt(index)
return index
}
private fun removeKeyAt(index: Int) {
keysArray.resetAt(index)
removeHashAt(presenceArray[index])
presenceArray[index] = TOMBSTONE
size--
}
private fun removeHashAt(removedHash: Int) {
var hash = removedHash
var hole = removedHash // will try to patch the hole in hash array
var probeDistance = 0
var patchAttemptsLeft = (maxProbeDistance * 2).coerceAtMost(hashSize / 2) // don't spend too much effort
while (true) {
if (hash-- == 0) hash = hashSize - 1
if (++probeDistance > maxProbeDistance) {
// too far away -- can release the hole, bad case will not happen
hashArray[hole] = 0
return
}
val index = hashArray[hash]
if (index == 0) {
// end of chain -- can release the hole, bad case will not happen
hashArray[hole] = 0
return
}
if (index < 0) {
// TOMBSTONE FOUND
// - <--- [ TS ] ------ [hole] ---> +
// \------------/
// probeDistance
// move tombstone into the hole
hashArray[hole] = TOMBSTONE
hole = hash
probeDistance = 0
} else {
val otherHash = hash(keysArray[index - 1])
// Bad case:
// - <--- [hash] ------ [hole] ------ [otherHash] ---> +
// \------------/
// probeDistance
if ((otherHash - hash) and (hashSize - 1) >= probeDistance) {
// move otherHash into the hole, move the hole
hashArray[hole] = index
presenceArray[index - 1] = hole
hole = hash
probeDistance = 0
}
}
// check how long we're patching holes
if (--patchAttemptsLeft < 0) {
// just place tombstone into the hole
hashArray[hole] = TOMBSTONE
return
}
}
}
internal fun containsEntry(entry: Map.Entry<K, V>): Boolean {
val index = findKey(entry.key)
if (index < 0) return false
return valuesArray!![index] == entry.value
}
private fun contentEquals(other: Map<*, *>): Boolean = size == other.size && containsAllEntries(other.entries)
internal fun containsAllEntries(m: Collection<Map.Entry<*, *>>): Boolean {
val it = m.iterator()
while (it.hasNext()) {
val entry = it.next()
try {
@Suppress("UNCHECKED_CAST") // todo: get rid of unchecked cast here somehow
if (!containsEntry(entry as Map.Entry<K, V>))
return false
} catch(e: ClassCastException) {
return false
}
}
return true
}
internal fun putEntry(entry: Map.Entry<K, V>): Boolean {
val index = addKey(entry.key)
val valuesArray = allocateValuesArray()
if (index >= 0) {
valuesArray[index] = entry.value
return true
}
val oldValue = valuesArray[-index - 1]
if (entry.value != oldValue) {
valuesArray[-index - 1] = entry.value
return true
}
return false
}
internal fun putAllEntries(from: Collection<Map.Entry<K, V>>): Boolean {
if (from.isEmpty()) return false
ensureExtraCapacity(from.size)
val it = from.iterator()
var updated = false
while (it.hasNext()) {
if (putEntry(it.next()))
updated = true
}
return updated
}
internal fun removeEntry(entry: Map.Entry<K, V>): Boolean {
val index = findKey(entry.key)
if (index < 0) return false
if (valuesArray!![index] != entry.value) return false
removeKeyAt(index)
return true
}
internal fun removeAllEntries(elements: Collection<Map.Entry<K, V>>): Boolean {
if (elements.isEmpty()) return false
val it = entriesIterator()
var updated = false
while (it.hasNext()) {
if (elements.contains(it.next())) {
it.remove()
updated = true
}
}
return updated
}
internal fun retainAllEntries(elements: Collection<Map.Entry<K, V>>): Boolean {
val it = entriesIterator()
var updated = false
while (it.hasNext()) {
if (!elements.contains(it.next())) {
it.remove()
updated = true
}
}
return updated
}
internal fun containsAllValues(elements: Collection<V>): Boolean {
val it = elements.iterator()
while (it.hasNext()) {
if (!containsValue(it.next()))
return false
}
return true
}
internal fun removeValue(element: V): Boolean {
val index = findValue(element)
if (index < 0) return false
removeKeyAt(index)
return true
}
internal fun removeAllValues(elements: Collection<V>): Boolean {
val it = valuesIterator()
var updated = false
while (it.hasNext()) {
if (elements.contains(it.next())) {
it.remove()
updated = true
}
}
return updated
}
internal fun retainAllValues(elements: Collection<V>): Boolean {
val it = valuesIterator()
var updated = false
while (it.hasNext()) {
if (!elements.contains(it.next())) {
it.remove()
updated = true
}
}
return updated
}
internal fun keysIterator() = KeysItr(this)
internal fun valuesIterator() = ValuesItr(this)
internal fun entriesIterator() = EntriesItr(this)
private companion object {
const val MAGIC = 2654435769L.toInt() // golden ratio
const val INITIAL_CAPACITY = 8
const val INITIAL_MAX_PROBE_DISTANCE = 2
const val TOMBSTONE = -1
fun computeHashSize(capacity: Int): Int = (capacity.coerceAtLeast(1) * 3).highestOneBit()
fun computeShift(hashSize: Int): Int = hashSize.numberOfLeadingZeros() + 1
}
internal open class Itr<K, V>(
internal val map: HashMap<K, V>
) {
internal var index = 0
internal var lastIndex: Int = -1
init {
initNext()
}
internal fun initNext() {
while (index < map.length && map.presenceArray[index] < 0)
index++
}
fun hasNext(): Boolean = index < map.length
fun remove() {
map.removeKeyAt(lastIndex)
lastIndex = -1
}
}
internal class KeysItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<K> {
override fun next(): K {
if (index >= map.length) throw IndexOutOfBoundsException()
lastIndex = index++
val result = map.keysArray[lastIndex]
initNext()
return result
}
}
internal class ValuesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map), MutableIterator<V> {
override fun next(): V {
if (index >= map.length) throw IndexOutOfBoundsException()
lastIndex = index++
val result = map.valuesArray!![lastIndex]
initNext()
return result
}
}
internal class EntriesItr<K, V>(map: HashMap<K, V>) : Itr<K, V>(map),
MutableIterator<MutableMap.MutableEntry<K, V>> {
override fun next(): EntryRef<K, V> {
if (index >= map.length) throw IndexOutOfBoundsException()
lastIndex = index++
val result = EntryRef(map, lastIndex)
initNext()
return result
}
internal fun nextHashCode(): Int {
if (index >= map.length) throw IndexOutOfBoundsException()
lastIndex = index++
val result = map.keysArray[lastIndex].hashCode() xor map.valuesArray!![lastIndex].hashCode()
initNext()
return result
}
fun nextAppendString(sb: StringBuilder) {
if (index >= map.length) throw IndexOutOfBoundsException()
lastIndex = index++
val key = map.keysArray[lastIndex]
if (key == map) sb.append("(this Map)") else sb.append(key)
sb.append('=')
val value = map.valuesArray!![lastIndex]
if (value == map) sb.append("(this Map)") else sb.append(value)
initNext()
}
}
internal class EntryRef<K, V>(
private val map: HashMap<K, V>,
private val index: Int
) : MutableMap.MutableEntry<K, V> {
override val key: K
get() = map.keysArray[index]
override val value: V
get() = map.valuesArray!![index]
override fun setValue(newValue: V): V {
val valuesArray = map.allocateValuesArray()
val oldValue = valuesArray[index]
valuesArray[index] = newValue
return oldValue
}
override fun equals(other: Any?): Boolean =
other is Map.Entry<*, *> &&
other.key == key &&
other.value == value
override fun hashCode(): Int = key.hashCode() xor value.hashCode()
override fun toString(): String = "$key=$value"
}
}
/**
* Constructs the specialized implementation of [HashMap] with [String] keys, which stores the keys as properties of
* JS object without hashing them.
*/
public fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> {
return HashMap<String, V>(InternalStringMap(EqualityComparator.HashCode)).apply { putAll(pairs) }
}
internal class HashMapValues<V> internal constructor(
val backing: HashMap<*, V>
) : MutableCollection<V> {
override val size: Int get() = backing.size
override fun isEmpty(): Boolean = backing.isEmpty()
override fun contains(element: V): Boolean = backing.containsValue(element)
override fun containsAll(elements: Collection<V>): Boolean = backing.containsAllValues(elements)
override fun add(element: V): Boolean = throw UnsupportedOperationException()
override fun addAll(elements: Collection<V>): Boolean = throw UnsupportedOperationException()
override fun clear() = backing.clear()
override fun iterator(): MutableIterator<V> = backing.valuesIterator()
override fun remove(element: V): Boolean = backing.removeValue(element)
override fun removeAll(elements: Collection<V>): Boolean = backing.removeAllValues(elements)
override fun retainAll(elements: Collection<V>): Boolean = backing.retainAllValues(elements)
override fun equals(other: Any?): Boolean =
other === this ||
other is Collection<*> &&
contentEquals(other)
override fun hashCode(): Int {
var result = 1
val it = iterator()
while (it.hasNext()) {
result = result * 31 + it.next().hashCode()
}
return result
}
// override fun toString(): String = collectionToString()
// ---------------------------- private ----------------------------
private fun contentEquals(other: Collection<*>): Boolean {
@Suppress("UNCHECKED_CAST") // todo: figure out something better
return size == other.size && backing.containsAllValues(other as Collection<V>)
}
}
internal class HashMapEntrySet<K, V> internal constructor(
val backing: HashMap<K, V>
) : MutableSet<MutableMap.MutableEntry<K, V>> {
override val size: Int get() = backing.size
override fun isEmpty(): Boolean = backing.isEmpty()
override fun contains(element: MutableMap.MutableEntry<K, V>): Boolean = backing.containsEntry(element)
override fun clear() = backing.clear()
override fun add(element: MutableMap.MutableEntry<K, V>): Boolean = backing.putEntry(element)
override fun remove(element: MutableMap.MutableEntry<K, V>): Boolean = backing.removeEntry(element)
override fun iterator(): MutableIterator<MutableMap.MutableEntry<K, V>> = backing.entriesIterator()
override fun containsAll(elements: Collection<MutableMap.MutableEntry<K, V>>): Boolean = backing.containsAllEntries(elements)
override fun addAll(elements: Collection<MutableMap.MutableEntry<K, V>>): Boolean = backing.putAllEntries(elements)
override fun removeAll(elements: Collection<MutableMap.MutableEntry<K, V>>): Boolean = backing.removeAllEntries(elements)
override fun retainAll(elements: Collection<MutableMap.MutableEntry<K, V>>): Boolean = backing.retainAllEntries(elements)
override fun equals(other: Any?): Boolean =
other === this ||
other is Set<*> &&
contentEquals(other)
override fun hashCode(): Int {
var result = 0
val it = iterator()
while (it.hasNext()) {
result += it.next().hashCode()
}
return result
}
// override fun toString(): String = collectionToString()
// ---------------------------- private ----------------------------
private fun contentEquals(other: Set<*>): Boolean {
@Suppress("UNCHECKED_CAST") // todo: get rid of unchecked cast here somehow
return size == other.size && backing.containsAllEntries(other as Collection<Map.Entry<*, *>>)
}
}
// This hash map keeps insertion order.
typealias LinkedHashMap<K, V> = HashMap<K, V>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,86 +13,70 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Based on GWT HashSet
* Copyright 2008 Google Inc.
*/
package kotlin.collections
/**
* The implementation of the [MutableSet] interface, backed by a [HashMap] instance.
*/
public open class HashSet<E> : AbstractMutableSet<E> {
class HashSet<K> internal constructor(
val backing: HashMap<K, *>
) : MutableSet<K>, AbstractMutableSet<K>() {
private val map: HashMap<E, Any>
constructor() : this(HashMap<K, Nothing>())
/**
* Constructs a new empty [HashSet].
*/
constructor() {
map = HashMap<E, Any>()
constructor(capacity: Int, loadFactor: Float = 0.5f) : this(HashMap<K, Nothing>(capacity))
constructor(c: Collection<K>) : this(c.size) {
addAll(c)
}
/**
* Constructs a new [HashSet] filled with the elements of the specified collection.
*/
constructor(elements: Collection<E>) {
map = HashMap<E, Any>(elements.size)
addAll(elements)
override val size: Int get() = backing.size
override fun isEmpty(): Boolean = backing.isEmpty()
override fun contains(element: K): Boolean = backing.containsKey(element)
override fun clear() = backing.clear()
override fun add(element: K): Boolean = backing.addKey(element) >= 0
override fun remove(element: K): Boolean = backing.removeKey(element) >= 0
override fun iterator(): MutableIterator<K> = backing.keysIterator()
override fun containsAll(elements: Collection<K>): Boolean {
val it = elements.iterator()
while (it.hasNext()) {
if (!contains(it.next()))
return false
}
return true
}
/**
* Constructs a new empty [HashSet].
*
* @param initialCapacity the initial capacity (ignored)
* @param loadFactor the load factor (ignored)
*
* @throws IllegalArgumentException if the initial capacity or load factor are negative
*/
constructor(initialCapacity: Int, loadFactor: Float = 0.0f) {
map = HashMap<E, Any>(initialCapacity, loadFactor)
override fun addAll(elements: Collection<K>): Boolean {
val it = elements.iterator()
var updated = false
while (it.hasNext()) {
if (add(it.next()))
updated = true
}
return updated
}
/**
* Protected constructor to specify the underlying map. This is used by
* LinkedHashSet.
* @param map underlying map to use.
*/
internal constructor(map: HashMap<E, Any>) {
this.map = map
override fun equals(other: Any?): Boolean {
return other === this ||
(other is Set<*>) &&
contentEquals(
@Suppress("UNCHECKED_CAST") (other as Set<K>))
}
override fun add(element: E): Boolean {
val old = map.put(element, this)
return old == null
override fun hashCode(): Int {
var result = 0
val it = iterator()
while (it.hasNext()) {
result += it.next()!!.hashCode()
}
return result
}
override fun clear() {
map.clear()
}
// override fun toString(): String = collectionToString()
// public override fun clone(): Any {
// return HashSet<E>(this)
// }
override operator fun contains(element: E): Boolean = map.containsKey(element)
override fun isEmpty(): Boolean = map.isEmpty()
override fun iterator(): MutableIterator<E> = map.keys.iterator()
override fun remove(element: E): Boolean = map.remove(element) != null
override val size: Int get() = map.size
// ---------------------------- private ----------------------------
private fun contentEquals(other: Set<K>): Boolean = size == other.size && containsAll(other)
}
/**
* Creates a new instance of the specialized implementation of [HashSet] with the specified [String] elements,
* which elements the keys as properties of JS object without hashing them.
*/
public fun stringSetOf(vararg elements: String): HashSet<String> {
return HashSet(stringMapOf<Any>()).apply { addAll(elements) }
}
// This hash set keeps insertion order.
typealias LinkedHashSet<V> = HashSet<V>

View File

@@ -1,261 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Based on GWT LinkedHashMap
* Copyright 2008 Google Inc.
*/
package kotlin.collections
import kotlin.collections.MutableMap.MutableEntry
/**
* Hash table based implementation of the [MutableMap] interface, which additionally preserves the insertion order
* of entries during the iteration.
*
* The insertion order is preserved by maintaining a doubly-linked list of all of its entries.
*/
public open class LinkedHashMap<K, V> : HashMap<K, V>, Map<K, V> {
/**
* The entry we use includes next/prev pointers for a doubly-linked circular
* list with a head node. This reduces the special cases we have to deal with
* in the list operations.
* Note that we duplicate the key from the underlying hash map so we can find
* the eldest entry. The alternative would have been to modify HashMap so more
* of the code was directly usable here, but this would have added some
* overhead to HashMap, or to reimplement most of the HashMap code here with
* small modifications. Paying a small storage cost only if you use
* LinkedHashMap and minimizing code size seemed like a better tradeoff
*/
private class ChainEntry<K, V>(key: K, value: V) : AbstractMutableMap.SimpleEntry<K, V>(key, value) {
internal var next: ChainEntry<K, V>? = null
internal var prev: ChainEntry<K, V>? = null
}
private inner class EntrySet : AbstractMutableSet<MutableEntry<K, V>>() {
private inner class EntryIterator : MutableIterator<MutableEntry<K, V>> {
// The last entry that was returned from this iterator.
private var last: ChainEntry<K, V>? = null
// The next entry to return from this iterator.
private var next: ChainEntry<K, V>? = null
init {
next = head
// recordLastKnownStructure(map, this)
}
override fun hasNext(): Boolean {
return next !== null
}
override fun next(): MutableEntry<K, V> {
// checkStructuralChange(map, this)
if (!hasNext()) throw NoSuchElementException()
val current = next!!
last = current
next = current.next.takeIf { it !== head }
return current
}
override fun remove() {
check(last != null)
// checkStructuralChange(map, this)
last!!.remove()
map.remove(last!!.key)
// recordLastKnownStructure(map, this)
last = null
}
}
override fun add(element: MutableEntry<K, V>): Boolean = throw UnsupportedOperationException("Add is not supported on entries")
override fun clear() {
this@LinkedHashMap.clear()
}
override operator fun contains(element: MutableEntry<K, V>): Boolean = containsEntry(element)
override operator fun iterator(): MutableIterator<MutableEntry<K, V>> = EntryIterator()
override fun remove(element: MutableEntry<K, V>): Boolean {
if (contains(element)) {
this@LinkedHashMap.remove(element.key)
return true
}
return false
}
override val size: Int get() = this@LinkedHashMap.size
}
/*
* The head of the insert order chain, which is a doubly-linked circular
* list.
*
* The most recently inserted node is at the end of the chain, ie.
* chain.prev.
*/
private var head: ChainEntry<K, V>? = null
/**
* Add this node to the end of the chain.
*/
private fun ChainEntry<K, V>.addToEnd() {
// This entry is not in the list.
check(next == null && prev == null)
val _head = head
if (_head == null) {
head = this
next = this
prev = this
} else {
// Chain is valid.
val _tail = checkNotNull(_head.prev)
// Update me.
prev = _tail
next = _head
// Update my new siblings: current head and old tail
_head.prev = this
_tail.next = this
}
}
/**
* Remove this node from the chain it is a part of.
*/
private fun ChainEntry<K, V>.remove() {
if (this.next === this) {
// if this is single element, remove head
head = null
}
else {
if (head === this) {
// if this is first element, move head to next
head = next
}
next!!.prev = prev
prev!!.next = next
}
next = null
prev = null
}
/*
* The hashmap that keeps track of our entries and the chain. Note that we
* duplicate the key here to eliminate changes to HashMap and minimize the
* code here, at the expense of additional space.
*/
private val map: HashMap<K, ChainEntry<K, V>>
/**
* Constructs an empty [LinkedHashMap] instance.
*/
constructor() : super() {
map = HashMap<K, ChainEntry<K, V>>()
}
internal constructor(backingMap: HashMap<K, Any>) : super() {
@Suppress("UNCHECKED_CAST") // expected to work due to erasure
map = backingMap as HashMap<K, ChainEntry<K, V>>
}
/**
* Constructs an empty [LinkedHashMap] instance.
*
* @param initialCapacity the initial capacity (ignored)
* @param loadFactor the load factor (ignored)
*
* @throws IllegalArgumentException if the initial capacity or load factor are negative
*/
constructor(initialCapacity: Int, loadFactor: Float = 0f) : super(initialCapacity, loadFactor) {
map = HashMap<K, ChainEntry<K, V>>()
}
/**
* Constructs an instance of [LinkedHashMap] filled with the contents of the specified [original] map.
*/
constructor(original: Map<out K, V>) {
map = HashMap<K, ChainEntry<K, V>>()
this.putAll(original)
}
override fun clear() {
map.clear()
head = null
}
// override fun clone(): Any {
// return LinkedHashMap(this)
// }
override fun containsKey(key: K): Boolean = map.containsKey(key)
override fun containsValue(value: V): Boolean {
var node: ChainEntry<K, V> = head ?: return false
do {
if (node.value == value) {
return true
}
node = node.next!!
} while (node !== head)
return false
}
override fun createEntrySet(): MutableSet<MutableMap.MutableEntry<K, V>> = EntrySet()
override operator fun get(key: K): V? = map.get(key)?.value
override fun put(key: K, value: V): V? {
val old = map.get(key)
if (old == null) {
val newEntry = ChainEntry(key, value)
map.put(key, newEntry)
newEntry.addToEnd()
return null
}
else {
return old.setValue(value)
}
}
override fun remove(key: K): V? {
val entry = map.remove(key)
if (entry != null) {
entry.remove()
return entry.value
}
return null
}
override val size: Int get() = map.size
}
/**
* Constructs the specialized implementation of [LinkedHashMap] with [String] keys, which stores the keys as properties of
* JS object without hashing them.
*/
public fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> {
return LinkedHashMap<String, V>(stringMapOf<Any>()).apply { putAll(pairs) }
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Based on GWT LinkedHashSet
* Copyright 2008 Google Inc.
*/
package kotlin.collections
/**
* The implementation of the [MutableSet] interface, backed by a [LinkedHashMap] instance.
*
* This implementation preserves the insertion order of elements during the iteration.
*/
public open class LinkedHashSet<E> : HashSet<E> {
internal constructor(map: LinkedHashMap<E, Any>) : super(map)
/**
* Constructs a new empty [LinkedHashSet].
*/
constructor() : super(LinkedHashMap<E, Any>())
/**
* Constructs a new [LinkedHashSet] filled with the elements of the specified collection.
*/
constructor(elements: Collection<E>) : super(LinkedHashMap<E, Any>()) {
addAll(elements)
}
/**
* Constructs a new empty [LinkedHashSet].
*
* @param initialCapacity the initial capacity (ignored)
* @param loadFactor the load factor (ignored)
*
* @throws IllegalArgumentException if the initial capacity or load factor are negative
*/
constructor(initialCapacity: Int, loadFactor: Float = 0.0f) : super(LinkedHashMap<E, Any>(initialCapacity, loadFactor))
// public override fun clone(): Any {
// return LinkedHashSet(this)
// }
}
/**
* Creates a new instance of the specialized implementation of [LinkedHashSet] with the specified [String] elements,
* which elements the keys as properties of JS object without hashing them.
*/
public fun linkedStringSetOf(vararg elements: String): LinkedHashSet<String> {
return LinkedHashSet(linkedStringMapOf<Any>()).apply { addAll(elements) }
}

View File

@@ -0,0 +1,95 @@
package kotlin.collections
/**
* Created by user on 7/13/17.
*/
internal fun <T> Array<T>.resetAt(index: Int) {
this.unsafeCast<Array<Any?>>()[index] = null
}
internal fun <T> Array<T>.resetRange(fromIndex: Int, toIndex: Int) {
val arr = this.unsafeCast<Array<Any?>>()
for (i in fromIndex until toIndex) {
arr[i] = null
}
}
fun Int.highestOneBit() : Int {
var index = 31
while (index >= 0) {
var mask = (1 shl index)
if ((mask and this) != 0) {
return mask
}
index--
}
return 0
}
fun Int.numberOfLeadingZeros() : Int {
var index = 31
while (index >= 0) {
var mask = (1 shl index)
if ((mask and this) != 0) {
return 31 - index
}
index--
}
return 0
}
internal fun <T> Array<T>.copyOfUninitializedElements(newSize: Int): Array<T> {
return this.copyOf(newSize).unsafeCast<Array<T>>()
}
internal fun IntArray.copyOfUninitializedElements(newSize: Int): IntArray {
return this.copyOf(newSize)
}
internal fun IntArray.fill(value: Int, fromIndex: Int, toIndex: Int) {
for (i in fromIndex until toIndex) {
this[i] = value
}
}
internal fun <T> arrayOfUninitializedElements(capacity: Int): Array<T> {
return arrayOfNulls<Any>(capacity).unsafeCast<Array<T>>()
}
/**
* Constructs the specialized implementation of [HashMap] with [String] keys, which stores the keys as properties of
* JS object without hashing them.
*/
internal fun <V> stringMapOf(vararg pairs: Pair<String, V>): HashMap<String, V> {
return HashMap<String, V>().apply { putAll(pairs) }
}
/**
* Creates a new instance of the specialized implementation of [HashSet] with the specified [String] elements,
* which elements the keys as properties of JS object without hashing them.
*/
internal fun stringSetOf(vararg elements: String): HashSet<String> {
return HashSet(stringMapOf<Any>()).apply { addAll(elements) }
}
/**
* Constructs the specialized implementation of [LinkedHashMap] with [String] keys, which stores the keys as properties of
* JS object without hashing them.
*/
public fun <V> linkedStringMapOf(vararg pairs: Pair<String, V>): LinkedHashMap<String, V> {
return LinkedHashMap<String, V>().apply { putAll(pairs) }
}
/**
* Creates a new instance of the specialized implementation of [LinkedHashSet] with the specified [String] elements,
* which elements the keys as properties of JS object without hashing them.
*/
public fun linkedStringSetOf(vararg elements: String): LinkedHashSet<String> {
return LinkedHashSet<String>().apply { addAll(elements) }
}
internal fun Any?.hashCode(): Int = this?.hashCode() ?: 0

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1108
// EXPECTED_REACHABLE_NODES: 1249
package foo
annotation class bar

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1119
// EXPECTED_REACHABLE_NODES: 1260
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1116
// EXPECTED_REACHABLE_NODES: 1257
package foo
fun run(a: A, arg: String, funRef:(A, String) -> String): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1254
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1119
// EXPECTED_REACHABLE_NODES: 1260
package foo
open class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1109
// EXPECTED_REACHABLE_NODES: 1250
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
package foo
class A(val x:Int) {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1254
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1109
// EXPECTED_REACHABLE_NODES: 1250
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
package foo
fun Int.sum0(other: Int): Int = this + other

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1109
// EXPECTED_REACHABLE_NODES: 1250
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1109
// EXPECTED_REACHABLE_NODES: 1250
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1109
// EXPECTED_REACHABLE_NODES: 1250
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1254
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1111
// EXPECTED_REACHABLE_NODES: 1252
// This test was adapted from compiler/testData/codegen/box/callableReference/function/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
// This test was adapted from compiler/testData/codegen/box/callableReference/function/local/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1121
// EXPECTED_REACHABLE_NODES: 1262
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1126
// EXPECTED_REACHABLE_NODES: 1267
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1125
// EXPECTED_REACHABLE_NODES: 1266
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1130
// EXPECTED_REACHABLE_NODES: 1269
package foo
import kotlin.reflect.KMutableProperty1

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1118
// EXPECTED_REACHABLE_NODES: 1259
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1127
// EXPECTED_REACHABLE_NODES: 1266
package foo
open class A(var msg:String) {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1123
// EXPECTED_REACHABLE_NODES: 1264
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1254
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1115
// EXPECTED_REACHABLE_NODES: 1256
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1120
// EXPECTED_REACHABLE_NODES: 1261
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1121
// EXPECTED_REACHABLE_NODES: 1262
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1121
// EXPECTED_REACHABLE_NODES: 1262
// This test was adapted from compiler/testData/codegen/box/callableReference/property/.
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1119
// EXPECTED_REACHABLE_NODES: 1258
package foo
var x = 1

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1253
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1094
// EXPECTED_REACHABLE_NODES: 1255
package foo
class A

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1254
package foo
var log = ""

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1251
package foo
class A

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1160
// EXPECTED_REACHABLE_NODES: 1299
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1253
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1099
// EXPECTED_REACHABLE_NODES: 1309
private inline fun typeOf(x: dynamic): String = js("typeof x").unsafeCast<String>()
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1122
// EXPECTED_REACHABLE_NODES: 1261
// KT-4130 object fields are not evaluated correctly
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1119
// EXPECTED_REACHABLE_NODES: 1260
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1141
// EXPECTED_REACHABLE_NODES: 1280
// See KT-6326, KT-6777
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
package foo
interface A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1121
// EXPECTED_REACHABLE_NODES: 1260
// See KT-11100
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1122
// EXPECTED_REACHABLE_NODES: 1261
package foo
interface Named {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1134
// EXPECTED_REACHABLE_NODES: 1273
// See KT-6203
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1126
// EXPECTED_REACHABLE_NODES: 1267
package foo
open class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1375
// EXPECTED_REACHABLE_NODES: 1523
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1252
package foo
fun test(f: () -> String): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1115
// EXPECTED_REACHABLE_NODES: 1256
package foo
val r = "OK"

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1117
// EXPECTED_REACHABLE_NODES: 1256
package foo
class A<T>(val a: T) {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1110
// EXPECTED_REACHABLE_NODES: 1251
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1121
// EXPECTED_REACHABLE_NODES: 1262
package foo
fun funfun(): Boolean {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1129
// EXPECTED_REACHABLE_NODES: 1268
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1115
// EXPECTED_REACHABLE_NODES: 1256
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
// KT-4218 Nested function literal on singleton object fails
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1122
// EXPECTED_REACHABLE_NODES: 1263
package foo
object A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1115
// EXPECTED_REACHABLE_NODES: 1256
// KT-4237 With in with
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1116
// EXPECTED_REACHABLE_NODES: 1255
// KT-4263 Wrong capturing a function literal variable
package foo

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1113
// EXPECTED_REACHABLE_NODES: 1252
package foo
fun test(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1255
package foo
class Foo {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1112
// EXPECTED_REACHABLE_NODES: 1253
package foo
fun box(): String {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1114
// EXPECTED_REACHABLE_NODES: 1253
package foo
val k = { "K" }

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1118
// EXPECTED_REACHABLE_NODES: 1257
package foo
// workaround for Rhino

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1117
// EXPECTED_REACHABLE_NODES: 1258
package foo
class A() {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1119
// EXPECTED_REACHABLE_NODES: 1260
package foo
class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1122
// EXPECTED_REACHABLE_NODES: 1261
package foo
class A(val a: String) {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1129
// EXPECTED_REACHABLE_NODES: 1268
package foo
open class A {

View File

@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1122
// EXPECTED_REACHABLE_NODES: 1263
// KT-2388
package foo

Some files were not shown because too many files have changed in this diff Show More