From c7bd70732ce9b311612053d7b366aba2d5ac92eb Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 27 Jan 2016 21:27:54 +0300 Subject: [PATCH] Inline-only in generated code --- libraries/stdlib/src/generated/_Arrays.kt | 363 ++++++++++++------ .../stdlib/src/generated/_Collections.kt | 38 +- libraries/stdlib/src/generated/_Maps.kt | 10 +- libraries/stdlib/src/generated/_Sequences.kt | 11 +- libraries/stdlib/src/generated/_Sets.kt | 6 +- libraries/stdlib/src/generated/_Strings.kt | 31 +- .../stdlib/src/kotlin/collections/Maps.kt | 4 +- .../stdlib/src/kotlin/text/regex/Regex.kt | 10 + .../src/templates/Aggregates.kt | 3 + .../kotlin-stdlib-gen/src/templates/Arrays.kt | 2 + .../src/templates/Elements.kt | 15 +- .../src/templates/Filtering.kt | 8 +- .../src/templates/Generators.kt | 4 + .../src/templates/Ordering.kt | 8 +- .../src/templates/Sequence.kt | 4 + .../src/templates/SpecialJVM.kt | 8 + 16 files changed, 350 insertions(+), 175 deletions(-) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 7f9bbf8b2fb..c0a89c7ee94 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -16,7 +16,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Array.component1(): T { return get(0) } @@ -24,7 +24,7 @@ public inline operator fun Array.component1(): T { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun BooleanArray.component1(): Boolean { return get(0) } @@ -32,7 +32,7 @@ public inline operator fun BooleanArray.component1(): Boolean { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ByteArray.component1(): Byte { return get(0) } @@ -40,7 +40,7 @@ public inline operator fun ByteArray.component1(): Byte { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun CharArray.component1(): Char { return get(0) } @@ -48,7 +48,7 @@ public inline operator fun CharArray.component1(): Char { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun DoubleArray.component1(): Double { return get(0) } @@ -56,7 +56,7 @@ public inline operator fun DoubleArray.component1(): Double { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun FloatArray.component1(): Float { return get(0) } @@ -64,7 +64,7 @@ public inline operator fun FloatArray.component1(): Float { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun IntArray.component1(): Int { return get(0) } @@ -72,7 +72,7 @@ public inline operator fun IntArray.component1(): Int { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun LongArray.component1(): Long { return get(0) } @@ -80,7 +80,7 @@ public inline operator fun LongArray.component1(): Long { /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ShortArray.component1(): Short { return get(0) } @@ -88,7 +88,7 @@ public inline operator fun ShortArray.component1(): Short { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Array.component2(): T { return get(1) } @@ -96,7 +96,7 @@ public inline operator fun Array.component2(): T { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun BooleanArray.component2(): Boolean { return get(1) } @@ -104,7 +104,7 @@ public inline operator fun BooleanArray.component2(): Boolean { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ByteArray.component2(): Byte { return get(1) } @@ -112,7 +112,7 @@ public inline operator fun ByteArray.component2(): Byte { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun CharArray.component2(): Char { return get(1) } @@ -120,7 +120,7 @@ public inline operator fun CharArray.component2(): Char { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun DoubleArray.component2(): Double { return get(1) } @@ -128,7 +128,7 @@ public inline operator fun DoubleArray.component2(): Double { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun FloatArray.component2(): Float { return get(1) } @@ -136,7 +136,7 @@ public inline operator fun FloatArray.component2(): Float { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun IntArray.component2(): Int { return get(1) } @@ -144,7 +144,7 @@ public inline operator fun IntArray.component2(): Int { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun LongArray.component2(): Long { return get(1) } @@ -152,7 +152,7 @@ public inline operator fun LongArray.component2(): Long { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ShortArray.component2(): Short { return get(1) } @@ -160,7 +160,7 @@ public inline operator fun ShortArray.component2(): Short { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Array.component3(): T { return get(2) } @@ -168,7 +168,7 @@ public inline operator fun Array.component3(): T { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun BooleanArray.component3(): Boolean { return get(2) } @@ -176,7 +176,7 @@ public inline operator fun BooleanArray.component3(): Boolean { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ByteArray.component3(): Byte { return get(2) } @@ -184,7 +184,7 @@ public inline operator fun ByteArray.component3(): Byte { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun CharArray.component3(): Char { return get(2) } @@ -192,7 +192,7 @@ public inline operator fun CharArray.component3(): Char { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun DoubleArray.component3(): Double { return get(2) } @@ -200,7 +200,7 @@ public inline operator fun DoubleArray.component3(): Double { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun FloatArray.component3(): Float { return get(2) } @@ -208,7 +208,7 @@ public inline operator fun FloatArray.component3(): Float { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun IntArray.component3(): Int { return get(2) } @@ -216,7 +216,7 @@ public inline operator fun IntArray.component3(): Int { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun LongArray.component3(): Long { return get(2) } @@ -224,7 +224,7 @@ public inline operator fun LongArray.component3(): Long { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ShortArray.component3(): Short { return get(2) } @@ -232,7 +232,7 @@ public inline operator fun ShortArray.component3(): Short { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Array.component4(): T { return get(3) } @@ -240,7 +240,7 @@ public inline operator fun Array.component4(): T { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun BooleanArray.component4(): Boolean { return get(3) } @@ -248,7 +248,7 @@ public inline operator fun BooleanArray.component4(): Boolean { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ByteArray.component4(): Byte { return get(3) } @@ -256,7 +256,7 @@ public inline operator fun ByteArray.component4(): Byte { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun CharArray.component4(): Char { return get(3) } @@ -264,7 +264,7 @@ public inline operator fun CharArray.component4(): Char { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun DoubleArray.component4(): Double { return get(3) } @@ -272,7 +272,7 @@ public inline operator fun DoubleArray.component4(): Double { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun FloatArray.component4(): Float { return get(3) } @@ -280,7 +280,7 @@ public inline operator fun FloatArray.component4(): Float { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun IntArray.component4(): Int { return get(3) } @@ -288,7 +288,7 @@ public inline operator fun IntArray.component4(): Int { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun LongArray.component4(): Long { return get(3) } @@ -296,7 +296,7 @@ public inline operator fun LongArray.component4(): Long { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ShortArray.component4(): Short { return get(3) } @@ -304,7 +304,7 @@ public inline operator fun ShortArray.component4(): Short { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Array.component5(): T { return get(4) } @@ -312,7 +312,7 @@ public inline operator fun Array.component5(): T { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun BooleanArray.component5(): Boolean { return get(4) } @@ -320,7 +320,7 @@ public inline operator fun BooleanArray.component5(): Boolean { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ByteArray.component5(): Byte { return get(4) } @@ -328,7 +328,7 @@ public inline operator fun ByteArray.component5(): Byte { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun CharArray.component5(): Char { return get(4) } @@ -336,7 +336,7 @@ public inline operator fun CharArray.component5(): Char { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun DoubleArray.component5(): Double { return get(4) } @@ -344,7 +344,7 @@ public inline operator fun DoubleArray.component5(): Double { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun FloatArray.component5(): Float { return get(4) } @@ -352,7 +352,7 @@ public inline operator fun FloatArray.component5(): Float { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun IntArray.component5(): Int { return get(4) } @@ -360,7 +360,7 @@ public inline operator fun IntArray.component5(): Int { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun LongArray.component5(): Long { return get(4) } @@ -368,7 +368,7 @@ public inline operator fun LongArray.component5(): Long { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun ShortArray.component5(): Short { return get(4) } @@ -439,69 +439,79 @@ public operator fun ShortArray.contains(element: Short): Boolean { /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun Array.elementAt(index: Int): T { +@kotlin.internal.InlineOnly +public inline fun Array.elementAt(index: Int): T { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun BooleanArray.elementAt(index: Int): Boolean { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.elementAt(index: Int): Boolean { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun ByteArray.elementAt(index: Int): Byte { +@kotlin.internal.InlineOnly +public inline fun ByteArray.elementAt(index: Int): Byte { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun CharArray.elementAt(index: Int): Char { +@kotlin.internal.InlineOnly +public inline fun CharArray.elementAt(index: Int): Char { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun DoubleArray.elementAt(index: Int): Double { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.elementAt(index: Int): Double { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun FloatArray.elementAt(index: Int): Float { +@kotlin.internal.InlineOnly +public inline fun FloatArray.elementAt(index: Int): Float { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun IntArray.elementAt(index: Int): Int { +@kotlin.internal.InlineOnly +public inline fun IntArray.elementAt(index: Int): Int { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun LongArray.elementAt(index: Int): Long { +@kotlin.internal.InlineOnly +public inline fun LongArray.elementAt(index: Int): Long { return get(index) } /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ -public fun ShortArray.elementAt(index: Int): Short { +@kotlin.internal.InlineOnly +public inline fun ShortArray.elementAt(index: Int): Short { return get(index) } /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun Array.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -509,6 +519,7 @@ public inline fun Array.elementAtOrElse(index: Int, defaultValue: (In /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun BooleanArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -516,6 +527,7 @@ public inline fun BooleanArray.elementAtOrElse(index: Int, defaultValue: (Int) - /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun ByteArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Byte): Byte { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -523,6 +535,7 @@ public inline fun ByteArray.elementAtOrElse(index: Int, defaultValue: (Int) -> B /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun CharArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -530,6 +543,7 @@ public inline fun CharArray.elementAtOrElse(index: Int, defaultValue: (Int) -> C /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun DoubleArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Double): Double { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -537,6 +551,7 @@ public inline fun DoubleArray.elementAtOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun FloatArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Float): Float { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -544,6 +559,7 @@ public inline fun FloatArray.elementAtOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun IntArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Int): Int { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -551,6 +567,7 @@ public inline fun IntArray.elementAtOrElse(index: Int, defaultValue: (Int) -> In /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun LongArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Long): Long { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -558,6 +575,7 @@ public inline fun LongArray.elementAtOrElse(index: Int, defaultValue: (Int) -> L /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Short): Short { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -565,69 +583,79 @@ public inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun Array.elementAtOrNull(index: Int): T? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun Array.elementAtOrNull(index: Int): T? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun BooleanArray.elementAtOrNull(index: Int): Boolean? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun BooleanArray.elementAtOrNull(index: Int): Boolean? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun ByteArray.elementAtOrNull(index: Int): Byte? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun ByteArray.elementAtOrNull(index: Int): Byte? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun CharArray.elementAtOrNull(index: Int): Char? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun CharArray.elementAtOrNull(index: Int): Char? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun DoubleArray.elementAtOrNull(index: Int): Double? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun DoubleArray.elementAtOrNull(index: Int): Double? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun FloatArray.elementAtOrNull(index: Int): Float? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun FloatArray.elementAtOrNull(index: Int): Float? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun IntArray.elementAtOrNull(index: Int): Int? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun IntArray.elementAtOrNull(index: Int): Int? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun LongArray.elementAtOrNull(index: Int): Long? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun LongArray.elementAtOrNull(index: Int): Long? { + return this.getOrNull(index) } /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun ShortArray.elementAtOrNull(index: Int): Short? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun ShortArray.elementAtOrNull(index: Int): Short? { + return this.getOrNull(index) } /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Array.find(predicate: (T) -> Boolean): T? { return firstOrNull(predicate) } @@ -635,6 +663,7 @@ public inline fun Array.find(predicate: (T) -> Boolean): T? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean? { return firstOrNull(predicate) } @@ -642,6 +671,7 @@ public inline fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? { return firstOrNull(predicate) } @@ -649,6 +679,7 @@ public inline fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun CharArray.find(predicate: (Char) -> Boolean): Char? { return firstOrNull(predicate) } @@ -656,6 +687,7 @@ public inline fun CharArray.find(predicate: (Char) -> Boolean): Char? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun DoubleArray.find(predicate: (Double) -> Boolean): Double? { return firstOrNull(predicate) } @@ -663,6 +695,7 @@ public inline fun DoubleArray.find(predicate: (Double) -> Boolean): Double? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun FloatArray.find(predicate: (Float) -> Boolean): Float? { return firstOrNull(predicate) } @@ -670,6 +703,7 @@ public inline fun FloatArray.find(predicate: (Float) -> Boolean): Float? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun IntArray.find(predicate: (Int) -> Boolean): Int? { return firstOrNull(predicate) } @@ -677,6 +711,7 @@ public inline fun IntArray.find(predicate: (Int) -> Boolean): Int? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun LongArray.find(predicate: (Long) -> Boolean): Long? { return firstOrNull(predicate) } @@ -684,6 +719,7 @@ public inline fun LongArray.find(predicate: (Long) -> Boolean): Long? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun ShortArray.find(predicate: (Short) -> Boolean): Short? { return firstOrNull(predicate) } @@ -691,6 +727,7 @@ public inline fun ShortArray.find(predicate: (Short) -> Boolean): Short? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Array.findLast(predicate: (T) -> Boolean): T? { return lastOrNull(predicate) } @@ -698,6 +735,7 @@ public inline fun Array.findLast(predicate: (T) -> Boolean): T? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun BooleanArray.findLast(predicate: (Boolean) -> Boolean): Boolean? { return lastOrNull(predicate) } @@ -705,6 +743,7 @@ public inline fun BooleanArray.findLast(predicate: (Boolean) -> Boolean): Boolea /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? { return lastOrNull(predicate) } @@ -712,6 +751,7 @@ public inline fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? { return lastOrNull(predicate) } @@ -719,6 +759,7 @@ public inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun DoubleArray.findLast(predicate: (Double) -> Boolean): Double? { return lastOrNull(predicate) } @@ -726,6 +767,7 @@ public inline fun DoubleArray.findLast(predicate: (Double) -> Boolean): Double? /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun FloatArray.findLast(predicate: (Float) -> Boolean): Float? { return lastOrNull(predicate) } @@ -733,6 +775,7 @@ public inline fun FloatArray.findLast(predicate: (Float) -> Boolean): Float? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun IntArray.findLast(predicate: (Int) -> Boolean): Int? { return lastOrNull(predicate) } @@ -740,6 +783,7 @@ public inline fun IntArray.findLast(predicate: (Int) -> Boolean): Int? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun LongArray.findLast(predicate: (Long) -> Boolean): Long? { return lastOrNull(predicate) } @@ -747,6 +791,7 @@ public inline fun LongArray.findLast(predicate: (Long) -> Boolean): Long? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun ShortArray.findLast(predicate: (Short) -> Boolean): Short? { return lastOrNull(predicate) } @@ -1060,6 +1105,7 @@ public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun Array.getOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1067,6 +1113,7 @@ public inline fun Array.getOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1074,6 +1121,7 @@ public inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Bool /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun ByteArray.getOrElse(index: Int, defaultValue: (Int) -> Byte): Byte { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1081,6 +1129,7 @@ public inline fun ByteArray.getOrElse(index: Int, defaultValue: (Int) -> Byte): /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1088,6 +1137,7 @@ public inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Double): Double { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1095,6 +1145,7 @@ public inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Doubl /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float): Float { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1102,6 +1153,7 @@ public inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float) /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun IntArray.getOrElse(index: Int, defaultValue: (Int) -> Int): Int { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1109,6 +1161,7 @@ public inline fun IntArray.getOrElse(index: Int, defaultValue: (Int) -> Int): In /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun LongArray.getOrElse(index: Int, defaultValue: (Int) -> Long): Long { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1116,6 +1169,7 @@ public inline fun LongArray.getOrElse(index: Int, defaultValue: (Int) -> Long): /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ +@kotlin.internal.InlineOnly public inline fun ShortArray.getOrElse(index: Int, defaultValue: (Int) -> Short): Short { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -5156,126 +5210,144 @@ public val ShortArray.indices: IntRange /** * Returns `true` if the array is empty. */ -public fun Array.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun Array.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun BooleanArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun ByteArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun ByteArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun CharArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun CharArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun DoubleArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun FloatArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun FloatArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun IntArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun IntArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun LongArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun LongArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is empty. */ -public fun ShortArray.isEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun ShortArray.isEmpty(): Boolean { return size == 0 } /** * Returns `true` if the array is not empty. */ -public fun Array.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun Array.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun BooleanArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun ByteArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun ByteArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun CharArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun CharArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun DoubleArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun FloatArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun FloatArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun IntArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun IntArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun LongArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun LongArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns `true` if the array is not empty. */ -public fun ShortArray.isNotEmpty(): Boolean { +@kotlin.internal.InlineOnly +public inline fun ShortArray.isNotEmpty(): Boolean { return !isEmpty() } @@ -8560,63 +8632,72 @@ public inline fun ShortArray.any(predicate: (Short) -> Boolean): Boolean { /** * Returns the number of elements in this array. */ -public fun Array.count(): Int { +@kotlin.internal.InlineOnly +public inline fun Array.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun BooleanArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun ByteArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun ByteArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun CharArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun CharArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun DoubleArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun FloatArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun FloatArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun IntArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun IntArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun LongArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun LongArray.count(): Int { return size } /** * Returns the number of elements in this array. */ -public fun ShortArray.count(): Int { +@kotlin.internal.InlineOnly +public inline fun ShortArray.count(): Int { return size } @@ -12229,7 +12310,8 @@ public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun Array.copyOf(): Array { +@kotlin.internal.InlineOnly +public inline fun Array.copyOf(): Array { return Arrays.copyOf(this, size) } @@ -12237,7 +12319,8 @@ public fun Array.copyOf(): Array { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun BooleanArray.copyOf(): BooleanArray { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOf(): BooleanArray { return Arrays.copyOf(this, size) } @@ -12245,7 +12328,8 @@ public fun BooleanArray.copyOf(): BooleanArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun ByteArray.copyOf(): ByteArray { +@kotlin.internal.InlineOnly +public inline fun ByteArray.copyOf(): ByteArray { return Arrays.copyOf(this, size) } @@ -12253,7 +12337,8 @@ public fun ByteArray.copyOf(): ByteArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun CharArray.copyOf(): CharArray { +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOf(): CharArray { return Arrays.copyOf(this, size) } @@ -12261,7 +12346,8 @@ public fun CharArray.copyOf(): CharArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun DoubleArray.copyOf(): DoubleArray { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOf(): DoubleArray { return Arrays.copyOf(this, size) } @@ -12269,7 +12355,8 @@ public fun DoubleArray.copyOf(): DoubleArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun FloatArray.copyOf(): FloatArray { +@kotlin.internal.InlineOnly +public inline fun FloatArray.copyOf(): FloatArray { return Arrays.copyOf(this, size) } @@ -12277,7 +12364,8 @@ public fun FloatArray.copyOf(): FloatArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun IntArray.copyOf(): IntArray { +@kotlin.internal.InlineOnly +public inline fun IntArray.copyOf(): IntArray { return Arrays.copyOf(this, size) } @@ -12285,7 +12373,8 @@ public fun IntArray.copyOf(): IntArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun LongArray.copyOf(): LongArray { +@kotlin.internal.InlineOnly +public inline fun LongArray.copyOf(): LongArray { return Arrays.copyOf(this, size) } @@ -12293,7 +12382,8 @@ public fun LongArray.copyOf(): LongArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun ShortArray.copyOf(): ShortArray { +@kotlin.internal.InlineOnly +public inline fun ShortArray.copyOf(): ShortArray { return Arrays.copyOf(this, size) } @@ -12301,7 +12391,8 @@ public fun ShortArray.copyOf(): ShortArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun Array.copyOf(newSize: Int): Array { +@kotlin.internal.InlineOnly +public inline fun Array.copyOf(newSize: Int): Array { return Arrays.copyOf(this, newSize) } @@ -12309,7 +12400,8 @@ public fun Array.copyOf(newSize: Int): Array { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun BooleanArray.copyOf(newSize: Int): BooleanArray { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOf(newSize: Int): BooleanArray { return Arrays.copyOf(this, newSize) } @@ -12317,7 +12409,8 @@ public fun BooleanArray.copyOf(newSize: Int): BooleanArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun ByteArray.copyOf(newSize: Int): ByteArray { +@kotlin.internal.InlineOnly +public inline fun ByteArray.copyOf(newSize: Int): ByteArray { return Arrays.copyOf(this, newSize) } @@ -12325,7 +12418,8 @@ public fun ByteArray.copyOf(newSize: Int): ByteArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun CharArray.copyOf(newSize: Int): CharArray { +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOf(newSize: Int): CharArray { return Arrays.copyOf(this, newSize) } @@ -12333,7 +12427,8 @@ public fun CharArray.copyOf(newSize: Int): CharArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun DoubleArray.copyOf(newSize: Int): DoubleArray { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOf(newSize: Int): DoubleArray { return Arrays.copyOf(this, newSize) } @@ -12341,7 +12436,8 @@ public fun DoubleArray.copyOf(newSize: Int): DoubleArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun FloatArray.copyOf(newSize: Int): FloatArray { +@kotlin.internal.InlineOnly +public inline fun FloatArray.copyOf(newSize: Int): FloatArray { return Arrays.copyOf(this, newSize) } @@ -12349,7 +12445,8 @@ public fun FloatArray.copyOf(newSize: Int): FloatArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun IntArray.copyOf(newSize: Int): IntArray { +@kotlin.internal.InlineOnly +public inline fun IntArray.copyOf(newSize: Int): IntArray { return Arrays.copyOf(this, newSize) } @@ -12357,7 +12454,8 @@ public fun IntArray.copyOf(newSize: Int): IntArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun LongArray.copyOf(newSize: Int): LongArray { +@kotlin.internal.InlineOnly +public inline fun LongArray.copyOf(newSize: Int): LongArray { return Arrays.copyOf(this, newSize) } @@ -12365,7 +12463,8 @@ public fun LongArray.copyOf(newSize: Int): LongArray { * Returns new array which is a copy of the original array. */ @kotlin.jvm.JvmVersion -public fun ShortArray.copyOf(newSize: Int): ShortArray { +@kotlin.internal.InlineOnly +public inline fun ShortArray.copyOf(newSize: Int): ShortArray { return Arrays.copyOf(this, newSize) } @@ -12373,7 +12472,8 @@ public fun ShortArray.copyOf(newSize: Int): ShortArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { +@kotlin.internal.InlineOnly +public inline fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12381,7 +12481,8 @@ public fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray { +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12389,7 +12490,8 @@ public fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray { +@kotlin.internal.InlineOnly +public inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12397,7 +12499,8 @@ public fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray { +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12405,7 +12508,8 @@ public fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray { +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12413,7 +12517,8 @@ public fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray { +@kotlin.internal.InlineOnly +public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12421,7 +12526,8 @@ public fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray { +@kotlin.internal.InlineOnly +public inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12429,7 +12535,8 @@ public fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray { +@kotlin.internal.InlineOnly +public inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12437,7 +12544,8 @@ public fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray { * Returns new array which is a copy of range of original array. */ @kotlin.jvm.JvmVersion -public fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { +@kotlin.internal.InlineOnly +public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12857,7 +12965,8 @@ public operator fun ShortArray.plus(elements: ShortArray): ShortArray { * Returns an array containing all elements of the original array and then the given [element]. */ @kotlin.jvm.JvmVersion -public fun Array.plusElement(element: T): Array { +@kotlin.internal.InlineOnly +public inline fun Array.plusElement(element: T): Array { return plus(element) } diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index e1a69455c1e..dbb5a455a14 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -16,7 +16,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Returns 1st *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun List.component1(): T { return get(0) } @@ -24,7 +24,7 @@ public inline operator fun List.component1(): T { /** * Returns 2nd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun List.component2(): T { return get(1) } @@ -32,7 +32,7 @@ public inline operator fun List.component2(): T { /** * Returns 3rd *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun List.component3(): T { return get(2) } @@ -40,7 +40,7 @@ public inline operator fun List.component3(): T { /** * Returns 4th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun List.component4(): T { return get(3) } @@ -48,7 +48,7 @@ public inline operator fun List.component4(): T { /** * Returns 5th *element* from the collection. */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun List.component5(): T { return get(4) } @@ -74,7 +74,8 @@ public fun Iterable.elementAt(index: Int): T { /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list. */ -public fun List.elementAt(index: Int): T { +@kotlin.internal.InlineOnly +public inline fun List.elementAt(index: Int): T { return get(index) } @@ -99,6 +100,7 @@ public fun Iterable.elementAtOrElse(index: Int, defaultValue: (Int) -> T) /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list. */ +@kotlin.internal.InlineOnly public inline fun List.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -124,13 +126,15 @@ public fun Iterable.elementAtOrNull(index: Int): T? { /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list. */ -public fun List.elementAtOrNull(index: Int): T? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun List.elementAtOrNull(index: Int): T? { + return this.getOrNull(index) } /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Iterable.find(predicate: (T) -> Boolean): T? { return firstOrNull(predicate) } @@ -138,6 +142,7 @@ public inline fun Iterable.find(predicate: (T) -> Boolean): T? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Iterable.findLast(predicate: (T) -> Boolean): T? { return lastOrNull(predicate) } @@ -145,6 +150,7 @@ public inline fun Iterable.findLast(predicate: (T) -> Boolean): T? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun List.findLast(predicate: (T) -> Boolean): T? { return lastOrNull(predicate) } @@ -227,6 +233,7 @@ public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean): T? { /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list. */ +@kotlin.internal.InlineOnly public inline fun List.getOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1320,7 +1327,8 @@ public inline fun Iterable.any(predicate: (T) -> Boolean): Boolean { /** * Returns the number of elements in this collection. */ -public fun Collection.count(): Int { +@kotlin.internal.InlineOnly +public inline fun Collection.count(): Int { return size } @@ -1657,7 +1665,8 @@ public operator fun Iterable.minus(elements: Sequence): List { /** * Returns a list containing all elements of the original collection without the first occurrence of the given [element]. */ -public fun Iterable.minusElement(element: T): List { +@kotlin.internal.InlineOnly +public inline fun Iterable.minusElement(element: T): List { return minus(element) } @@ -1771,14 +1780,16 @@ public operator fun Iterable.plus(elements: Sequence): List { /** * Returns a list containing all elements of the original collection and then the given [element]. */ -public fun Collection.plusElement(element: T): List { +@kotlin.internal.InlineOnly +public inline fun Collection.plusElement(element: T): List { return plus(element) } /** * Returns a list containing all elements of the original collection and then the given [element]. */ -public fun Iterable.plusElement(element: T): List { +@kotlin.internal.InlineOnly +public inline fun Iterable.plusElement(element: T): List { return plus(element) } @@ -1857,7 +1868,8 @@ public fun Iterable.joinToString(separator: CharSequence = ", ", prefix: /** * Returns this collection as an [Iterable]. */ -public fun Iterable.asIterable(): Iterable { +@kotlin.internal.InlineOnly +public inline fun Iterable.asIterable(): Iterable { return this } diff --git a/libraries/stdlib/src/generated/_Maps.kt b/libraries/stdlib/src/generated/_Maps.kt index a426b8ad588..b1fd7c64c9e 100644 --- a/libraries/stdlib/src/generated/_Maps.kt +++ b/libraries/stdlib/src/generated/_Maps.kt @@ -103,7 +103,8 @@ public inline fun Map.any(predicate: (Map.Entry) -> Boolean): /** * Returns the number of entries in this map. */ -public fun Map.count(): Int { +@kotlin.internal.InlineOnly +public inline fun Map.count(): Int { return size } @@ -127,6 +128,7 @@ public inline fun Map.forEach(action: (Map.Entry) -> Unit): U /** * Returns the first entry yielding the largest value of the given function or `null` if there are no entries. */ +@kotlin.internal.InlineOnly public inline fun > Map.maxBy(selector: (Map.Entry) -> R): Map.Entry? { return entries.maxBy(selector) } @@ -134,7 +136,8 @@ public inline fun > Map.maxBy(selector: (Map.Entry /** * Returns the first entry having the largest value according to the provided [comparator] or `null` if there are no entries. */ -public fun Map.maxWith(comparator: Comparator>): Map.Entry? { +@kotlin.internal.InlineOnly +public inline fun Map.maxWith(comparator: Comparator>): Map.Entry? { return entries.maxWith(comparator) } @@ -171,7 +174,8 @@ public inline fun Map.none(predicate: (Map.Entry) -> Boolean) /** * Creates an [Iterable] instance that wraps the original map returning its entries when being iterated. */ -public fun Map.asIterable(): Iterable> { +@kotlin.internal.InlineOnly +public inline fun Map.asIterable(): Iterable> { return entries } diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index b816fb3ae73..f89ac2af925 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -62,6 +62,7 @@ public fun Sequence.elementAtOrNull(index: Int): T? { /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Sequence.find(predicate: (T) -> Boolean): T? { return firstOrNull(predicate) } @@ -69,6 +70,7 @@ public inline fun Sequence.find(predicate: (T) -> Boolean): T? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ +@kotlin.internal.InlineOnly public inline fun Sequence.findLast(predicate: (T) -> Boolean): T? { return lastOrNull(predicate) } @@ -1053,7 +1055,8 @@ public operator fun Sequence.minus(elements: Sequence): Sequence { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. */ -public fun Sequence.minusElement(element: T): Sequence { +@kotlin.internal.InlineOnly +public inline fun Sequence.minusElement(element: T): Sequence { return minus(element) } @@ -1112,7 +1115,8 @@ public operator fun Sequence.plus(elements: Sequence): Sequence { /** * Returns a sequence containing all elements of the original sequence and then the given [element]. */ -public fun Sequence.plusElement(element: T): Sequence { +@kotlin.internal.InlineOnly +public inline fun Sequence.plusElement(element: T): Sequence { return plus(element) } @@ -1174,7 +1178,8 @@ public fun Sequence.asIterable(): Iterable { /** * Returns this sequence as a [Sequence]. */ -public fun Sequence.asSequence(): Sequence { +@kotlin.internal.InlineOnly +public inline fun Sequence.asSequence(): Sequence { return this } diff --git a/libraries/stdlib/src/generated/_Sets.kt b/libraries/stdlib/src/generated/_Sets.kt index e69c5257a59..49d158a48dd 100644 --- a/libraries/stdlib/src/generated/_Sets.kt +++ b/libraries/stdlib/src/generated/_Sets.kt @@ -57,7 +57,8 @@ public operator fun Set.minus(elements: Sequence): Set { /** * Returns a set containing all elements of the original set except the given [element]. */ -public fun Set.minusElement(element: T): Set { +@kotlin.internal.InlineOnly +public inline fun Set.minusElement(element: T): Set { return minus(element) } @@ -104,7 +105,8 @@ public operator fun Set.plus(elements: Sequence): Set { /** * Returns a set containing all elements of the original set and then the given [element]. */ -public fun Set.plusElement(element: T): Set { +@kotlin.internal.InlineOnly +public inline fun Set.plusElement(element: T): Set { return plus(element) } diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index f2acef0a189..9944a7ea2e4 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -16,13 +16,15 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence. */ -public fun CharSequence.elementAt(index: Int): Char { +@kotlin.internal.InlineOnly +public inline fun CharSequence.elementAt(index: Int): Char { return get(index) } /** * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence. */ +@kotlin.internal.InlineOnly public inline fun CharSequence.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -30,13 +32,15 @@ public inline fun CharSequence.elementAtOrElse(index: Int, defaultValue: (Int) - /** * Returns a character at the given [index] or `null` if the [index] is out of bounds of this char sequence. */ -public fun CharSequence.elementAtOrNull(index: Int): Char? { - return if (index >= 0 && index <= lastIndex) get(index) else null +@kotlin.internal.InlineOnly +public inline fun CharSequence.elementAtOrNull(index: Int): Char? { + return this.getOrNull(index) } /** * Returns the first character matching the given [predicate], or `null` if no such character was found. */ +@kotlin.internal.InlineOnly public inline fun CharSequence.find(predicate: (Char) -> Boolean): Char? { return firstOrNull(predicate) } @@ -44,6 +48,7 @@ public inline fun CharSequence.find(predicate: (Char) -> Boolean): Char? { /** * Returns the last character matching the given [predicate], or `null` if no such character was found. */ +@kotlin.internal.InlineOnly public inline fun CharSequence.findLast(predicate: (Char) -> Boolean): Char? { return lastOrNull(predicate) } @@ -85,6 +90,7 @@ public inline fun CharSequence.firstOrNull(predicate: (Char) -> Boolean): Char? /** * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence. */ +@kotlin.internal.InlineOnly public inline fun CharSequence.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -387,14 +393,9 @@ public fun CharSequence.slice(indices: Iterable): CharSequence { /** * Returns a string containing characters of the original string at specified [indices]. */ -public fun String.slice(indices: Iterable): String { - val size = indices.collectionSizeOrDefault(10) - if (size == 0) return "" - val result = StringBuilder(size) - for (i in indices) { - result.append(get(i)) - } - return result.toString() +@kotlin.internal.InlineOnly +public inline fun String.slice(indices: Iterable): String { + return (this as CharSequence).slice(indices).toString() } /** @@ -487,8 +488,9 @@ public fun CharSequence.reversed(): CharSequence { /** * Returns a string with characters in reversed order. */ -public fun String.reversed(): String { - return StringBuilder(this).reverse().toString() +@kotlin.internal.InlineOnly +public inline fun String.reversed(): String { + return (this as CharSequence).reversed().toString() } /** @@ -809,7 +811,8 @@ public inline fun CharSequence.any(predicate: (Char) -> Boolean): Boolean { /** * Returns the length of this char sequence. */ -public fun CharSequence.count(): Int { +@kotlin.internal.InlineOnly +public inline fun CharSequence.count(): Int { return length } diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index af12b1f7448..ffdce6e983c 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -145,7 +145,7 @@ public fun <@kotlin.internal.OnlyInputTypes K, V> MutableMap.remove(ke * } * ``` */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Map.Entry.component1(): K = key /** @@ -157,7 +157,7 @@ public inline operator fun Map.Entry.component1(): K = key * } * ``` */ -@Suppress("NOTHING_TO_INLINE") +@kotlin.internal.InlineOnly public inline operator fun Map.Entry.component2(): V = value /** diff --git a/libraries/stdlib/src/kotlin/text/regex/Regex.kt b/libraries/stdlib/src/kotlin/text/regex/Regex.kt index 0cf44cf06cc..39fbad3e0ab 100644 --- a/libraries/stdlib/src/kotlin/text/regex/Regex.kt +++ b/libraries/stdlib/src/kotlin/text/regex/Regex.kt @@ -94,15 +94,25 @@ public interface MatchResult { @Suppress("NOTHING_TO_INLINE") @kotlin.jvm.JvmVersion public class Destructured internal constructor(public val match: MatchResult) { + @kotlin.internal.InlineOnly public operator inline fun component1(): String = match.groupValues[1] + @kotlin.internal.InlineOnly public operator inline fun component2(): String = match.groupValues[2] + @kotlin.internal.InlineOnly public operator inline fun component3(): String = match.groupValues[3] + @kotlin.internal.InlineOnly public operator inline fun component4(): String = match.groupValues[4] + @kotlin.internal.InlineOnly public operator inline fun component5(): String = match.groupValues[5] + @kotlin.internal.InlineOnly public operator inline fun component6(): String = match.groupValues[6] + @kotlin.internal.InlineOnly public operator inline fun component7(): String = match.groupValues[7] + @kotlin.internal.InlineOnly public operator inline fun component8(): String = match.groupValues[8] + @kotlin.internal.InlineOnly public operator inline fun component9(): String = match.groupValues[9] + @kotlin.internal.InlineOnly public operator inline fun component10(): String = match.groupValues[10] /** * Returns destructured group values as a list of strings. diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index d36f39eabc3..1a1f5522654 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -95,6 +95,7 @@ fun aggregates(): List { return count """ } + inline(CharSequences, Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) { Inline.Only } doc(CharSequences) { "Returns the length of this char sequence."} body(CharSequences) { "return length" @@ -315,6 +316,7 @@ fun aggregates(): List { return maxElem """ } + inline(Maps) { Inline.Only } body(Maps) { "return entries.maxBy(selector)" } } @@ -346,6 +348,7 @@ fun aggregates(): List { return max """ } + inline(Maps) { Inline.Only } body(Maps) { "return entries.maxWith(comparator)" } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt index 3a9084d811d..fd1db835f25 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt @@ -6,6 +6,7 @@ fun arrays(): List { val templates = arrayListOf() templates add f("isEmpty()") { + inline(Inline.Only) only(ArraysOfObjects, ArraysOfPrimitives) doc { "Returns `true` if the array is empty." } returns("Boolean") @@ -15,6 +16,7 @@ fun arrays(): List { } templates add f("isNotEmpty()") { + inline(Inline.Only) only(ArraysOfObjects, ArraysOfPrimitives) doc { "Returns `true` if the array is not empty." } returns("Boolean") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 6e467a16242..215b1e69506 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -204,6 +204,7 @@ fun elements(): List { return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index.") } """ } + inline(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { Inline.Only } body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return get(index) @@ -244,7 +245,7 @@ fun elements(): List { return defaultValue(index) """ } - inline(true, CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) + inline(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { Inline.Only } body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) @@ -255,7 +256,7 @@ fun elements(): List { templates add f("getOrElse(index: Int, defaultValue: (Int) -> T)") { doc { f -> "Returns ${f.element.prefixWithArticle()} at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this ${f.collection}." } returns("T") - inline(true) + inline(Inline.Only) only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) body { """ @@ -298,9 +299,10 @@ fun elements(): List { return null """ } + inline(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { Inline.Only } body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ - return if (index >= 0 && index <= lastIndex) get(index) else null + return this.getOrNull(index) """ } } @@ -422,7 +424,7 @@ fun elements(): List { } templates add f("find(predicate: (T) -> Boolean)") { - inline(true) + inline(Inline.Only) include(CharSequences) doc { f -> "Returns the first ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." } returns("T?") @@ -590,7 +592,7 @@ fun elements(): List { } templates add f("findLast(predicate: (T) -> Boolean)") { - inline(true) + inline(Inline.Only) include(Lists, CharSequences) doc { f -> "Returns the last ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." } returns("T?") @@ -740,8 +742,7 @@ fun elements(): List { templates addAll (1..5).map { n -> f("component$n()") { operator(true) - inline(true) - annotations("""@Suppress("NOTHING_TO_INLINE")""") + inline(Inline.Only) fun getOrdinal(n: Int) = n.toString() + when (n) { 1 -> "st" 2 -> "nd" diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index 0bc41f9367c..8aa006d9114 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -542,7 +542,7 @@ fun filtering(): List { doc(CharSequences, Strings) { f -> "Returns a ${f.collection} containing ${f.element.pluralize()} of the original ${f.collection} at specified [indices]." } returns(CharSequences, Strings) { "SELF" } - body(CharSequences, Strings) { f -> + body(CharSequences) { """ val size = indices.collectionSizeOrDefault(10) if (size == 0) return "" @@ -550,9 +550,13 @@ fun filtering(): List { for (i in indices) { result.append(get(i)) } - return result${toResult(f)} + return result """ } + inline(Strings) { Inline.Only } + body(Strings) { + "return (this as CharSequence).slice(indices).toString()" + } } templates add f("slice(indices: IntRange)") { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index f2612a7f24c..2cad8fde76d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -6,6 +6,8 @@ fun generators(): List { val templates = arrayListOf() templates add f("plusElement(element: T)") { + inline(Inline.Only) + only(Iterables, Collections, Sets, Sequences) doc { "Returns a list containing all elements of the original collection and then the given [element]." } doc(Sets) { "Returns a set containing all elements of the original set and then the given [element]." } @@ -218,6 +220,8 @@ fun generators(): List { } templates add f("minusElement(element: T)") { + inline(Inline.Only) + only(Iterables, Sets, Sequences) doc { "Returns a list containing all elements of the original collection without the first occurrence of the given [element]." } doc(Sets) { "Returns a set containing all elements of the original set except the given [element]." } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt index 0dc990201c4..da89071410c 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt @@ -49,11 +49,15 @@ fun ordering(): List { doc(CharSequences, Strings) { f -> "Returns a ${f.collection} with characters in reversed order." } returns(CharSequences, Strings) { "SELF" } - body(CharSequences, Strings) { f -> + body(CharSequences) { f -> """ - return StringBuilder(this).reverse()${ if (f == Strings) ".toString()" else "" } + return StringBuilder(this).reverse() """ } + inline(Strings) { Inline.Only } + body(Strings) { + "return (this as CharSequence).reversed().toString()" + } exclude(Sequences) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt index 21ce0c17989..bb7163a9efb 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt @@ -21,6 +21,9 @@ fun sequences(): List { } """ } + + inline(Iterables, Maps) { Inline.Only } + doc(Iterables) { "Returns this collection as an [Iterable]." } body(Iterables) { "return this" } body(Maps) { "return entries" } @@ -59,6 +62,7 @@ fun sequences(): List { } doc(Sequences) { "Returns this sequence as a [Sequence]."} + inline(Sequences) { Inline.Only } body(Sequences) { "return this" } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 2f96a10fd08..fd2358bb080 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -6,6 +6,8 @@ fun specialJVM(): List { val templates = arrayListOf() templates add f("plusElement(element: T)") { + inline(Inline.Only) + only(InvariantArraysOfObjects) returns("SELF") doc { "Returns an array containing all elements of the original array and then the given [element]." } @@ -64,6 +66,8 @@ fun specialJVM(): List { templates add f("copyOfRange(fromIndex: Int, toIndex: Int)") { + inline(Inline.Only) + only(InvariantArraysOfObjects, ArraysOfPrimitives) doc { "Returns new array which is a copy of range of original array." } returns("SELF") @@ -73,6 +77,8 @@ fun specialJVM(): List { } templates add f("copyOf()") { + inline(Inline.Only) + only(InvariantArraysOfObjects, ArraysOfPrimitives) doc { "Returns new array which is a copy of the original array." } returns("SELF") @@ -83,6 +89,8 @@ fun specialJVM(): List { // This overload can cause nulls if array size is expanding, hence different return overload templates add f("copyOf(newSize: Int)") { + inline(Inline.Only) + only(InvariantArraysOfObjects, ArraysOfPrimitives) doc { "Returns new array which is a copy of the original array." } returns("SELF")