From 61416b3d142c3a08c29a1b0b578243359d965e36 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 6 Oct 2015 14:31:19 +0300 Subject: [PATCH] Adjust stdlib to `size` transformation --- js/js.libraries/src/core/domUtils.kt | 4 ++-- js/js.libraries/src/core/javautil.kt | 14 +++++++------- js/js.libraries/src/core/regex.kt | 2 +- libraries/stdlib/src/generated/_Arrays.kt | 16 ++++++++-------- libraries/stdlib/src/kotlin/collections/JUtil.kt | 2 +- .../src/kotlin/collections/MapWithDefault.kt | 4 ++-- libraries/stdlib/src/kotlin/collections/Maps.kt | 2 +- .../src/kotlin/collections/ReversedViews.kt | 2 +- libraries/stdlib/src/kotlin/collections/Sets.kt | 2 +- libraries/stdlib/src/kotlin/dom/Dom.kt | 4 ++-- .../stdlib/src/kotlin/text/regex/RegexJVM.kt | 2 +- .../src/templates/SpecialJVM.kt | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/js/js.libraries/src/core/domUtils.kt b/js/js.libraries/src/core/domUtils.kt index b1974648b25..931d7c8fd66 100644 --- a/js/js.libraries/src/core/domUtils.kt +++ b/js/js.libraries/src/core/domUtils.kt @@ -19,7 +19,7 @@ package org.w3c.dom import java.util.AbstractList private class HTMLCollectionListView(val collection: HTMLCollection) : AbstractList() { - override fun size(): Int = collection.length + override val size: Int get() = collection.length override fun get(index: Int): HTMLElement = when { @@ -32,7 +32,7 @@ public fun HTMLCollection.asList(): List = HTMLCollectionListView(t public fun HTMLCollection?.toElementList(): List = this?.asList() ?: emptyList() private class DOMTokenListView(val delegate: DOMTokenList) : AbstractList() { - override fun size(): Int = delegate.length + override val size: Int get() = delegate.length override fun get(index: Int) = when { diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 965500a6939..e0e9f117620 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -26,7 +26,7 @@ public abstract class AbstractCollection() : MutableCollection { override fun retainAll(c: Collection): Boolean = noImpl override fun clear(): Unit = noImpl - abstract override fun size(): Int + abstract override val size: Int override fun hashCode(): Int = noImpl override fun equals(other: Any?): Boolean = noImpl @@ -51,7 +51,7 @@ public abstract class AbstractList() : AbstractCollection(), MutableList = noImpl - override fun size(): Int = noImpl + override val size: Int get() = noImpl override fun equals(other: Any?): Boolean = noImpl @@ -61,7 +61,7 @@ public abstract class AbstractList() : AbstractCollection(), MutableList(capacity: Int = 0) : AbstractList() { override fun get(index: Int): E = noImpl - override fun size(): Int = noImpl + override val size: Int get() = noImpl } @library @@ -81,7 +81,7 @@ public open class LinkedList() : AbstractList() { public open class HashSet( initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR ) : AbstractCollection(), MutableSet { - override fun size(): Int = noImpl + override val size: Int get() = noImpl } @library @@ -90,19 +90,19 @@ public interface SortedSet : Set { @library public open class TreeSet() : AbstractCollection(), MutableSet, SortedSet { - override fun size(): Int = noImpl + override val size: Int get() = noImpl } @library public open class LinkedHashSet( initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR ) : HashSet(initialCapacity, loadFactor), MutableSet { - override fun size(): Int = noImpl + override val size: Int get() = noImpl } @library public open class HashMap(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap { - override fun size(): Int = noImpl + override val size: Int get() = noImpl override fun isEmpty(): Boolean = noImpl @Suppress("BASE_WITH_NULLABLE_UPPER_BOUND") override fun get(key: Any?): V? = noImpl diff --git a/js/js.libraries/src/core/regex.kt b/js/js.libraries/src/core/regex.kt index 19e8d5677bb..99e324fcd79 100644 --- a/js/js.libraries/src/core/regex.kt +++ b/js/js.libraries/src/core/regex.kt @@ -177,7 +177,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? { get() = match[0]!! override val groups: MatchGroupCollection = object : MatchGroupCollection { - override fun size(): Int = match.size() + override val size: Int get() = match.size() override fun isEmpty(): Boolean = size() == 0 override fun contains(o: Any?): Boolean = this.any { it == o } diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 219ad3ab488..0a6d9f152cb 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -10445,7 +10445,7 @@ public fun Array.asList(): List { @kotlin.jvm.JvmVersion public fun BooleanArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Boolean) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10461,7 +10461,7 @@ public fun BooleanArray.asList(): List { @kotlin.jvm.JvmVersion public fun ByteArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Byte) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10477,7 +10477,7 @@ public fun ByteArray.asList(): List { @kotlin.jvm.JvmVersion public fun CharArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Char) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10493,7 +10493,7 @@ public fun CharArray.asList(): List { @kotlin.jvm.JvmVersion public fun DoubleArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Double) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10509,7 +10509,7 @@ public fun DoubleArray.asList(): List { @kotlin.jvm.JvmVersion public fun FloatArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Float) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10525,7 +10525,7 @@ public fun FloatArray.asList(): List { @kotlin.jvm.JvmVersion public fun IntArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Int) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10541,7 +10541,7 @@ public fun IntArray.asList(): List { @kotlin.jvm.JvmVersion public fun LongArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Long) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator @@ -10557,7 +10557,7 @@ public fun LongArray.asList(): List { @kotlin.jvm.JvmVersion public fun ShortArray.asList(): List { return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Short) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator diff --git a/libraries/stdlib/src/kotlin/collections/JUtil.kt b/libraries/stdlib/src/kotlin/collections/JUtil.kt index 8103c0920d4..cc4332aa9e0 100644 --- a/libraries/stdlib/src/kotlin/collections/JUtil.kt +++ b/libraries/stdlib/src/kotlin/collections/JUtil.kt @@ -20,7 +20,7 @@ internal object EmptyList : List, Serializable { override fun hashCode(): Int = 1 override fun toString(): String = "[]" - override fun size(): Int = 0 + override val size: Int get() = 0 override fun isEmpty(): Boolean = true override fun contains(o: Any?): Boolean = false override fun containsAll(c: Collection): Boolean = c.isEmpty() diff --git a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt index 85f97fd56a7..36cf8b0c32e 100644 --- a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt +++ b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt @@ -65,7 +65,7 @@ private class MapWithDefaultImpl(public override val map: Map, pr override fun equals(other: Any?): Boolean = map.equals(other) override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() - override fun size(): Int = map.size() + override val size: Int get() = map.size() override fun isEmpty(): Boolean = map.isEmpty() override fun containsKey(key: Any?): Boolean = map.containsKey(key) override fun containsValue(value: Any?): Boolean = map.containsValue(value) @@ -81,7 +81,7 @@ private class MutableMapWithDefaultImpl(public override val map: MutableMa override fun equals(other: Any?): Boolean = map.equals(other) override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() - override fun size(): Int = map.size() + override val size: Int get() = map.size() override fun isEmpty(): Boolean = map.isEmpty() override fun containsKey(key: Any?): Boolean = map.containsKey(key) override fun containsValue(value: Any?): Boolean = map.containsValue(value) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index acc82f6d6e4..db067f39fec 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -11,7 +11,7 @@ private object EmptyMap : Map, Serializable { override fun hashCode(): Int = 0 override fun toString(): String = "{}" - override fun size(): Int = 0 + override val size: Int get() = 0 override fun isEmpty(): Boolean = true override fun containsKey(key: Any?): Boolean = false diff --git a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt index dfc919acfbc..42343476518 100644 --- a/libraries/stdlib/src/kotlin/collections/ReversedViews.kt +++ b/libraries/stdlib/src/kotlin/collections/ReversedViews.kt @@ -22,7 +22,7 @@ import java.util.AbstractList import kotlin.platform.platformName private open class ReversedListReadOnly(protected open val delegate: List) : AbstractList() { - override fun size(): Int = delegate.size() + override val size: Int get() = delegate.size() override fun get(index: Int): T = delegate[index.flipIndex()] protected fun Int.flipIndex(): Int = if (this in 0..size() - 1) size() - this - 1 else throw IndexOutOfBoundsException("index $this should be in range [${0..size() - 1}]") diff --git a/libraries/stdlib/src/kotlin/collections/Sets.kt b/libraries/stdlib/src/kotlin/collections/Sets.kt index c48ba38bf20..032732dbb8f 100644 --- a/libraries/stdlib/src/kotlin/collections/Sets.kt +++ b/libraries/stdlib/src/kotlin/collections/Sets.kt @@ -12,7 +12,7 @@ internal object EmptySet : Set, Serializable { override fun hashCode(): Int = 0 override fun toString(): String = "[]" - override fun size(): Int = 0 + override val size: Int get() = 0 override fun isEmpty(): Boolean = true override fun contains(o: Any?): Boolean = false override fun containsAll(c: Collection): Boolean = c.isEmpty() diff --git a/libraries/stdlib/src/kotlin/dom/Dom.kt b/libraries/stdlib/src/kotlin/dom/Dom.kt index e03577b0571..bb09db73c53 100644 --- a/libraries/stdlib/src/kotlin/dom/Dom.kt +++ b/libraries/stdlib/src/kotlin/dom/Dom.kt @@ -211,7 +211,7 @@ public fun Node.removeFromParent() { } private class NodeListAsList(private val delegate: NodeList) : AbstractList() { - override fun size(): Int = delegate.length + override val size: Int get() = delegate.length override fun get(index: Int): Node = when { index in 0..size() - 1 -> delegate.item(index)!! @@ -231,7 +231,7 @@ private class ElementListAsList(private val nodeList: NodeList) : AbstractList): Boolean = c.all({contains(it)}) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 8817bcc4d15..583e23c8dfb 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -228,7 +228,7 @@ fun specialJVM(): List { body(ArraysOfPrimitives) { """ return object : AbstractList(), RandomAccess { - override fun size(): Int = this@asList.size() + override val size: Int get() = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as T) override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator