diff --git a/runtime/src/main/kotlin/konan/internal/Char.kt b/runtime/src/main/kotlin/konan/internal/Char.kt index 8d5e4cb8467..c9e01f25d1e 100644 --- a/runtime/src/main/kotlin/konan/internal/Char.kt +++ b/runtime/src/main/kotlin/konan/internal/Char.kt @@ -33,10 +33,13 @@ public inline operator fun Char.plus(other: String) : String = this.toString() + * - Applying the method [toLowerCase] to each character produces the same result */ public fun Char.equals(other: Char, ignoreCase: Boolean = false): Boolean { + @Suppress("DEPRECATED_IDENTITY_EQUALS") if (this === other) return true if (!ignoreCase) return false + @Suppress("DEPRECATED_IDENTITY_EQUALS") if (this.toUpperCase() === other.toUpperCase()) return true + @Suppress("DEPRECATED_IDENTITY_EQUALS") if (this.toLowerCase() === other.toLowerCase()) return true return false } diff --git a/runtime/src/main/kotlin/konan/internal/Intrinsics.kt b/runtime/src/main/kotlin/konan/internal/Intrinsics.kt index c36eda7a23d..84f2f403140 100644 --- a/runtime/src/main/kotlin/konan/internal/Intrinsics.kt +++ b/runtime/src/main/kotlin/konan/internal/Intrinsics.kt @@ -33,6 +33,7 @@ import kotlinx.cinterop.NativePtr @Intrinsic external fun areEqualByValue(first: NativePointed?, second: NativePointed?): Boolean @Intrinsic external fun areEqualByValue(first: CPointer<*>?, second: CPointer<*>?): Boolean +@Suppress("NOTHING_TO_INLINE") inline fun areEqual(first: Any?, second: Any?): Boolean { return if (first == null) second == null else first.equals(second) } \ No newline at end of file diff --git a/runtime/src/main/kotlin/konan/internal/KPropertyImpl.kt b/runtime/src/main/kotlin/konan/internal/KPropertyImpl.kt index 25c1ffbfe7f..ed38053a25e 100644 --- a/runtime/src/main/kotlin/konan/internal/KPropertyImpl.kt +++ b/runtime/src/main/kotlin/konan/internal/KPropertyImpl.kt @@ -34,7 +34,7 @@ open class KProperty0Impl(override val name: String, val getter: () -> R) } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KProperty0Impl + val otherKProperty = other as? KProperty0Impl<*> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter } @@ -58,7 +58,7 @@ open class KProperty1Impl(override val name: String, val getter: (T) - } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KProperty1Impl + val otherKProperty = other as? KProperty1Impl<*, *> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter } @@ -82,7 +82,7 @@ open class KProperty2Impl(override val name: String, val getter: } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KProperty2Impl + val otherKProperty = other as? KProperty2Impl<*, *, *> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter } @@ -104,7 +104,7 @@ class KMutableProperty0Impl(name: String, getter: () -> R, val setter: (R) -> } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KMutableProperty0Impl + val otherKProperty = other as? KMutableProperty0Impl<*> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter } @@ -126,7 +126,7 @@ class KMutableProperty1Impl(name: String, getter: (T) -> R, val setter: (T } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KMutableProperty1Impl + val otherKProperty = other as? KMutableProperty1Impl<*, *> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter } @@ -148,7 +148,7 @@ class KMutableProperty2Impl(name: String, getter: (T1, T2) -> R, val } override fun equals(other: Any?): Boolean { - val otherKProperty = other as? KMutableProperty2Impl + val otherKProperty = other as? KMutableProperty2Impl<* ,*, *> if (otherKProperty == null) return false return name == otherKProperty.name && getter == otherKProperty.getter && setter == otherKProperty.setter } diff --git a/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt b/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt index af8ec91dd0f..b9cac57d59d 100644 --- a/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt +++ b/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt @@ -77,5 +77,6 @@ fun > valuesForEnum(values: Array): Array val result = Array(values.size) for (value in values) result[value.ordinal] = value + @Suppress("UNCHECKED_CAST") return result as Array } \ No newline at end of file diff --git a/runtime/src/main/kotlin/konan/internal/Strings.kt b/runtime/src/main/kotlin/konan/internal/Strings.kt index 09070fceb20..353c7df184f 100644 --- a/runtime/src/main/kotlin/konan/internal/Strings.kt +++ b/runtime/src/main/kotlin/konan/internal/Strings.kt @@ -169,6 +169,7 @@ external public fun String.toUpperCase(): String * Returns a copy of this string converted to lower case using the rules of the default locale. */ @SymbolName("Kotlin_String_toLowerCase") +@Suppress("NOTHING_TO_INLINE") external public inline fun String.toLowerCase(): String /** diff --git a/runtime/src/main/kotlin/kotlin/Arrays.kt b/runtime/src/main/kotlin/kotlin/Arrays.kt index 270b1512f99..07ca5148857 100644 --- a/runtime/src/main/kotlin/kotlin/Arrays.kt +++ b/runtime/src/main/kotlin/kotlin/Arrays.kt @@ -2583,56 +2583,67 @@ public inline fun Collection.toTypedArray(): Array { val result = arrayOfNulls(size) var index = 0 for (element in this) result[index++] = element + @Suppress("UNCHECKED_CAST") return result as Array } /** * Returns an array containing the specified elements. */ +@Suppress("UNCHECKED_CAST") public inline fun arrayOf(vararg elements: T): Array = elements as Array private val kEmptyArray = arrayOf() +@Suppress("UNCHECKED_CAST") public fun emptyArray() = kEmptyArray as Array /** * Returns an array containing the specified [Double] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun doubleArrayOf(vararg elements: Double) = elements /** * Returns an array containing the specified [Float] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun floatArrayOf(vararg elements: Float) = elements /** * Returns an array containing the specified [Long] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun longArrayOf(vararg elements: Long) = elements /** * Returns an array containing the specified [Int] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun intArrayOf(vararg elements: Int) = elements /** * Returns an array containing the specified characters. */ +@Suppress("NOTHING_TO_INLINE") public inline fun charArrayOf(vararg elements: Char) = elements /** * Returns an array containing the specified [Short] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun shortArrayOf(vararg elements: Short) = elements /** * Returns an array containing the specified [Byte] numbers. */ +@Suppress("NOTHING_TO_INLINE") public inline fun byteArrayOf(vararg elements: Byte) = elements /** * Returns an array containing the specified boolean values. */ +@Suppress("NOTHING_TO_INLINE") public inline fun booleanArrayOf(vararg elements: Boolean) = elements /** diff --git a/runtime/src/main/kotlin/kotlin/Assertions.kt b/runtime/src/main/kotlin/kotlin/Assertions.kt index fe340810bfd..58231448fac 100644 --- a/runtime/src/main/kotlin/kotlin/Assertions.kt +++ b/runtime/src/main/kotlin/kotlin/Assertions.kt @@ -20,6 +20,7 @@ package kotlin * Throws an [AssertionError] if the [value] is false * and runtime assertions have been enabled during compilation. */ +@Suppress("NOTHING_TO_INLINE") public inline fun assert(value: Boolean) { assert(value) { "Assertion failed" } } diff --git a/runtime/src/main/kotlin/kotlin/Enum.kt b/runtime/src/main/kotlin/kotlin/Enum.kt index 25b42a22525..bb0164ac982 100644 --- a/runtime/src/main/kotlin/kotlin/Enum.kt +++ b/runtime/src/main/kotlin/kotlin/Enum.kt @@ -48,6 +48,7 @@ public abstract class Enum>(public val name: String, public val ordin } } +@Suppress("UNUSED_PARAMETER") fun > enumValueOf(name: String): T { throw Exception("Call to this function should've been lowered") } diff --git a/runtime/src/main/kotlin/kotlin/Lazy.kt b/runtime/src/main/kotlin/kotlin/Lazy.kt index 3a290a55b0b..2fb3e16d682 100644 --- a/runtime/src/main/kotlin/kotlin/Lazy.kt +++ b/runtime/src/main/kotlin/kotlin/Lazy.kt @@ -83,6 +83,7 @@ public fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy = * Also this behavior can be changed in the future. */ @FixmeConcurrency +@Suppress("UNUSED_PARAMETER") public fun lazy(lock: Any?, initializer: () -> T): Lazy = TODO()//SynchronizedLazyImpl(initializer, lock) /** diff --git a/runtime/src/main/kotlin/kotlin/Primitives.kt b/runtime/src/main/kotlin/kotlin/Primitives.kt index 9d58db20dda..a06489396a4 100644 --- a/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -154,22 +154,22 @@ public final class Byte : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Byte") - external public operator fun mod(other: Byte): Int + external public operator fun rem(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Short") - external public operator fun mod(other: Short): Int + external public operator fun rem(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Int") - external public operator fun mod(other: Int): Int + external public operator fun rem(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Long") - external public operator fun mod(other: Long): Long + external public operator fun rem(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Float") - external public operator fun mod(other: Float): Float + external public operator fun rem(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Byte_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Byte_inc") @@ -381,22 +381,22 @@ public final class Short : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Byte") - external public operator fun mod(other: Byte): Int + external public operator fun rem(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Short") - external public operator fun mod(other: Short): Int + external public operator fun rem(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Int") - external public operator fun mod(other: Int): Int + external public operator fun rem(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Long") - external public operator fun mod(other: Long): Long + external public operator fun rem(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Float") - external public operator fun mod(other: Float): Float + external public operator fun rem(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Short_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Short_inc") @@ -608,22 +608,22 @@ public final class Int : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Byte") - external public operator fun mod(other: Byte): Int + external public operator fun rem(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Short") - external public operator fun mod(other: Short): Int + external public operator fun rem(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Int") - external public operator fun mod(other: Int): Int + external public operator fun rem(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Long") - external public operator fun mod(other: Long): Long + external public operator fun rem(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Float") - external public operator fun mod(other: Float): Float + external public operator fun rem(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Int_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Int_inc") @@ -704,33 +704,6 @@ public final class Int : Number(), Comparable { public override fun hashCode(): Int { return this } - - // TODO: make extensions. - fun highestOneBit() : Int { - var index = 31 - - while (index >= 0) { - var mask = (1 shl index) - if ((mask and this) != 0) { - return mask - } - index-- - } - return 0 - } - - fun numberOfLeadingZeros() : Int { - var index = 31 - - while (index >= 0) { - var mask = (1 shl index) - if ((mask and this) != 0) { - return 31 - index - } - index-- - } - return 0 - } } /** @@ -871,22 +844,22 @@ public final class Long : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Byte") - external public operator fun mod(other: Byte): Long + external public operator fun rem(other: Byte): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Short") - external public operator fun mod(other: Short): Long + external public operator fun rem(other: Short): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Int") - external public operator fun mod(other: Int): Long + external public operator fun rem(other: Int): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Long") - external public operator fun mod(other: Long): Long + external public operator fun rem(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Float") - external public operator fun mod(other: Float): Float + external public operator fun rem(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Long_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Long_inc") @@ -988,16 +961,19 @@ public final class Float : Number(), Comparable { /** * A constant holding the positive infinity value of Float. */ + @Suppress("DIVISION_BY_ZERO") public val POSITIVE_INFINITY: Float = 1.0f / 0.0f /** * A constant holding the negative infinity value of Float. */ + @Suppress("DIVISION_BY_ZERO") public val NEGATIVE_INFINITY: Float = -1.0f / 0.0f /** * A constant holding the "not a number" value of Float. */ + @Suppress("DIVISION_BY_ZERO") public val NaN: Float = 0.0f / 0.0f } @@ -1122,22 +1098,22 @@ public final class Float : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Byte") - external public operator fun mod(other: Byte): Float + external public operator fun rem(other: Byte): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Short") - external public operator fun mod(other: Short): Float + external public operator fun rem(other: Short): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Int") - external public operator fun mod(other: Int): Float + external public operator fun rem(other: Int): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Long") - external public operator fun mod(other: Long): Float + external public operator fun rem(other: Long): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Float") - external public operator fun mod(other: Float): Float + external public operator fun rem(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Float_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Float_inc") @@ -1205,16 +1181,19 @@ public final class Double : Number(), Comparable { /** * A constant holding the positive infinity value of Double. */ + @Suppress("DIVISION_BY_ZERO") public val POSITIVE_INFINITY: Double = 1.0 / 0.0 /** * A constant holding the negative infinity value of Double. */ + @Suppress("DIVISION_BY_ZERO") public val NEGATIVE_INFINITY: Double = -1.0 / 0.0 /** * A constant holding the "not a number" value of Double. */ + @Suppress("DIVISION_BY_ZERO") public val NaN: Double = 0.0 / 0.0 } @@ -1339,22 +1318,22 @@ public final class Double : Number(), Comparable { /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Byte") - external public operator fun mod(other: Byte): Double + external public operator fun rem(other: Byte): Double /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Short") - external public operator fun mod(other: Short): Double + external public operator fun rem(other: Short): Double /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Int") - external public operator fun mod(other: Int): Double + external public operator fun rem(other: Int): Double /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Long") - external public operator fun mod(other: Long): Double + external public operator fun rem(other: Long): Double /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Float") - external public operator fun mod(other: Float): Double + external public operator fun rem(other: Float): Double /** Calculates the remainder of dividing this value by the other value. */ @SymbolName("Kotlin_Double_mod_Double") - external public operator fun mod(other: Double): Double + external public operator fun rem(other: Double): Double /** Increments this value. */ @SymbolName("Kotlin_Double_inc") diff --git a/runtime/src/main/kotlin/kotlin/Throwable.kt b/runtime/src/main/kotlin/kotlin/Throwable.kt index b316b1f8593..a010eb2e656 100644 --- a/runtime/src/main/kotlin/kotlin/Throwable.kt +++ b/runtime/src/main/kotlin/kotlin/Throwable.kt @@ -42,6 +42,7 @@ public open class Throwable(open val message: String?, open val cause: Throwable this.cause?.printEnclosedStackTrace(this) } + @Suppress("UNUSED_PARAMETER") private fun printEnclosedStackTrace(enclosing: Throwable) { // TODO: should skip common stack frames print("Caused by: ") diff --git a/runtime/src/main/kotlin/kotlin/collections/Collections.kt b/runtime/src/main/kotlin/kotlin/collections/Collections.kt index 35f3fc33034..1ea71feb52f 100644 --- a/runtime/src/main/kotlin/kotlin/collections/Collections.kt +++ b/runtime/src/main/kotlin/kotlin/collections/Collections.kt @@ -128,6 +128,7 @@ public inline fun List?.orEmpty(): List = this ?: emptyList() * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection`. */ @kotlin.internal.InlineOnly +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public inline fun <@kotlin.internal.OnlyInputTypes T> Collection.containsAll( elements: Collection): Boolean = this.containsAll(elements) @@ -555,6 +556,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable.indexOf(element: T): /** * Returns first index of [element], or -1 if the list does not contain element. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public fun <@kotlin.internal.OnlyInputTypes T> List.indexOf(element: T): Int { return indexOf(element) } @@ -674,6 +676,7 @@ public inline fun List.last(predicate: (T) -> Boolean): T { /** * Returns last index of [element], or -1 if the collection does not contain element. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public fun <@kotlin.internal.OnlyInputTypes T> Iterable.lastIndexOf(element: T): Int { if (this is List) return this.lastIndexOf(element) var lastIndex = -1 @@ -689,6 +692,7 @@ public fun <@kotlin.internal.OnlyInputTypes T> Iterable.lastIndexOf(element: /** * Returns last index of [element], or -1 if the list does not contain element. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public fun <@kotlin.internal.OnlyInputTypes T> List.lastIndexOf(element: T): Int { return lastIndexOf(element) } @@ -2192,6 +2196,7 @@ public infix fun Iterable.zip(other: Array): List> { return zip(other) { t1, t2 -> t1 to t2 } } +@Suppress("NOTHING_TO_INLINE") inline fun min(x1: Int, x2: Int) = if (x1 < x2) x1 else x2 /** diff --git a/runtime/src/main/kotlin/kotlin/collections/Maps.kt b/runtime/src/main/kotlin/kotlin/collections/Maps.kt index 679e613af3c..036db3e9a16 100644 --- a/runtime/src/main/kotlin/kotlin/collections/Maps.kt +++ b/runtime/src/main/kotlin/kotlin/collections/Maps.kt @@ -38,6 +38,7 @@ private object EmptyMap : Map { * Returns an empty read-only map of specified type. The returned map is serializable (JVM). * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap */ +@Suppress("UNCHECKED_CAST") public fun emptyMap(): Map = EmptyMap as Map /** @@ -162,6 +163,7 @@ public inline fun <@kotlin.internal.OnlyInputTypes K> Map.containsKey( * Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`. */ @kotlin.internal.InlineOnly +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public inline fun Map.containsValue(value: V): Boolean = this.containsValue(value) diff --git a/runtime/src/main/kotlin/kotlin/sequences/Sequences.kt b/runtime/src/main/kotlin/kotlin/sequences/Sequences.kt index 7751b5aaf06..ef3df0fc8bb 100644 --- a/runtime/src/main/kotlin/kotlin/sequences/Sequences.kt +++ b/runtime/src/main/kotlin/kotlin/sequences/Sequences.kt @@ -952,6 +952,7 @@ public inline fun Sequence<*>.filterIsInstance(): Sequence<@kotlin.i * Appends all elements that are instances of specified type parameter R to the given [destination]. */ @FixmeReified +@Suppress("UNUSED_PARAMETER") public inline fun > Sequence<*>.filterIsInstanceTo(destination: C): C { //for (element in this) if (element is R) destination.add(element) //return destination diff --git a/runtime/src/main/kotlin/kotlin/text/Appendable.kt b/runtime/src/main/kotlin/kotlin/text/Appendable.kt index 0a442504d39..f273243eb1e 100644 --- a/runtime/src/main/kotlin/kotlin/text/Appendable.kt +++ b/runtime/src/main/kotlin/kotlin/text/Appendable.kt @@ -52,7 +52,7 @@ public fun StringBuilder.append(vararg value: Any?): StringBuilder { internal fun Appendable.appendElement(element: T, transform: ((T) -> CharSequence)?) { when { transform != null -> append(transform(element)) - element is CharSequence? -> append(element) + element is CharSequence -> append(element) element is Char -> append(element) else -> append(element.toString()) } diff --git a/runtime/src/main/kotlin/kotlin/text/Char.kt b/runtime/src/main/kotlin/kotlin/text/Char.kt index f4f03be830e..6e56f717c26 100644 --- a/runtime/src/main/kotlin/kotlin/text/Char.kt +++ b/runtime/src/main/kotlin/kotlin/text/Char.kt @@ -51,6 +51,7 @@ external public fun Char.isIdentifierIgnorable(): Boolean * Returns `true` if this character is an ISO control character. */ @SymbolName("Kotlin_Char_isISOControl") +@Suppress("NOTHING_TO_INLINE") external public inline fun Char.isISOControl(): Boolean /** diff --git a/runtime/src/main/kotlin/kotlin/text/Strings.kt b/runtime/src/main/kotlin/kotlin/text/Strings.kt index e97752a1e4a..01d7cbad09d 100644 --- a/runtime/src/main/kotlin/kotlin/text/Strings.kt +++ b/runtime/src/main/kotlin/kotlin/text/Strings.kt @@ -304,6 +304,7 @@ public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence */ @kotlin.internal.InlineOnly @Deprecated("Use parameters named startIndex and endIndex.", ReplaceWith("subSequence(startIndex = start, endIndex = end)")) +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSequence(start, end) /** @@ -714,7 +715,7 @@ public fun CharSequence.endsWith(char: Char, ignoreCase: Boolean = false): Boole */ public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = false): Boolean { if (!ignoreCase && this is String && prefix is String) - return (this as String).startsWith(prefix) + return this.startsWith(prefix) else return regionMatchesImpl(0, prefix, 0, prefix.length, ignoreCase) } @@ -724,7 +725,7 @@ public fun CharSequence.startsWith(prefix: CharSequence, ignoreCase: Boolean = f */ public fun CharSequence.startsWith(prefix: CharSequence, startIndex: Int, ignoreCase: Boolean = false): Boolean { if (!ignoreCase && this is String && prefix is String) - return (this as String).startsWith(prefix, startIndex) + return this.startsWith(prefix, startIndex) else return regionMatchesImpl(startIndex, prefix, 0, prefix.length, ignoreCase) } @@ -734,7 +735,7 @@ public fun CharSequence.startsWith(prefix: CharSequence, startIndex: Int, ignore */ public fun CharSequence.endsWith(suffix: CharSequence, ignoreCase: Boolean = false): Boolean { if (!ignoreCase && this is String && suffix is String) - return (this as String).endsWith(suffix) + return this.endsWith(suffix) else return regionMatchesImpl(length - suffix.length, suffix, 0, suffix.length, ignoreCase) } diff --git a/runtime/src/main/kotlin/kotlin/util/Sort.kt b/runtime/src/main/kotlin/kotlin/util/Sort.kt index 7e5107eedc3..d12ae1dd26d 100644 --- a/runtime/src/main/kotlin/kotlin/util/Sort.kt +++ b/runtime/src/main/kotlin/kotlin/util/Sort.kt @@ -22,6 +22,7 @@ import kotlin.comparisons.* private fun partition(array: Array, left: Int, right: Int): Int { var i = left var j = right + @Suppress("UNCHECKED_CAST") val pivot = array[(left + right) / 2] as Comparable while (i <= j) { while (pivot.compareTo(array[i]) > 0) { @@ -81,9 +82,11 @@ private fun quickSort( internal fun sortArrayWith( array: Array, fromIndex: Int, toIndex: Int, comparator: Comparator) { + @Suppress("UNCHECKED_CAST") quickSort(array as Array, fromIndex, toIndex, comparator) } internal fun sortArrayComparable(array: Array) { + @Suppress("UNCHECKED_CAST") quickSort(array as Array, 0, array.size - 1) } \ No newline at end of file