diff --git a/js/js.libraries/src/core/generated/_ArraysJs.kt b/js/js.libraries/src/core/generated/_ArraysJs.kt index 9b1a62c720d..ed8bbffb334 100644 --- a/js/js.libraries/src/core/generated/_ArraysJs.kt +++ b/js/js.libraries/src/core/generated/_ArraysJs.kt @@ -2158,6 +2158,7 @@ public inline fun Array.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } @@ -2175,6 +2176,7 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Byte } @@ -2192,6 +2194,7 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Short } @@ -2209,6 +2212,7 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean): Int { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Int } @@ -2226,6 +2230,7 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Long } @@ -2243,6 +2248,7 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Float } @@ -2260,6 +2266,7 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Double } @@ -2277,6 +2284,7 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Boolean } @@ -2294,6 +2302,7 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Char } diff --git a/js/js.libraries/src/core/generated/_CollectionsJs.kt b/js/js.libraries/src/core/generated/_CollectionsJs.kt index 575519856ca..fd3617c9c0c 100644 --- a/js/js.libraries/src/core/generated/_CollectionsJs.kt +++ b/js/js.libraries/src/core/generated/_CollectionsJs.kt @@ -255,6 +255,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") // false warning, extension takes precedence in some cases public fun <@kotlin.internal.OnlyInputTypes T> List.indexOf(element: T): Int { return indexOf(element) } @@ -355,6 +356,7 @@ public inline fun Iterable.last(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return last as T } @@ -389,6 +391,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") // false warning, extension takes precedence in some cases public fun <@kotlin.internal.OnlyInputTypes T> List.lastIndexOf(element: T): Int { return lastIndexOf(element) } @@ -486,6 +489,7 @@ public inline fun Iterable.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } diff --git a/js/js.libraries/src/core/generated/_SequencesJs.kt b/js/js.libraries/src/core/generated/_SequencesJs.kt index a0c7e8fb5b1..4c4b2262fdb 100644 --- a/js/js.libraries/src/core/generated/_SequencesJs.kt +++ b/js/js.libraries/src/core/generated/_SequencesJs.kt @@ -209,6 +209,7 @@ public inline fun Sequence.last(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return last as T } @@ -289,6 +290,7 @@ public inline fun Sequence.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } diff --git a/js/js.libraries/src/core/generated/_StringsJs.kt b/js/js.libraries/src/core/generated/_StringsJs.kt index 657387e433e..4cc6b649cd0 100644 --- a/js/js.libraries/src/core/generated/_StringsJs.kt +++ b/js/js.libraries/src/core/generated/_StringsJs.kt @@ -189,6 +189,7 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char { } } if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Char } diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index 074f587703a..94683ad81b5 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -148,6 +148,7 @@ public header fun <@kotlin.internal.OnlyInputTypes T> Iterable.indexOf(elemen /** * Returns first index of [element], or -1 if the list does not contain element. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases public header fun <@kotlin.internal.OnlyInputTypes T> List.indexOf(element: T): Int /** @@ -202,6 +203,7 @@ public header fun <@kotlin.internal.OnlyInputTypes T> Iterable.lastIndexOf(el /** * Returns last index of [element], or -1 if the list does not contain element. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases public header fun <@kotlin.internal.OnlyInputTypes T> List.lastIndexOf(element: T): Int /** diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 45e4095bea5..c95e1707ea8 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -2156,6 +2156,7 @@ public inline fun Array.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } @@ -2173,6 +2174,7 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Byte } @@ -2190,6 +2192,7 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Short } @@ -2207,6 +2210,7 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean): Int { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Int } @@ -2224,6 +2228,7 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Long } @@ -2241,6 +2246,7 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Float } @@ -2258,6 +2264,7 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Double } @@ -2275,6 +2282,7 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Boolean } @@ -2292,6 +2300,7 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { } } if (!found) throw NoSuchElementException("Array contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Char } @@ -13663,6 +13672,7 @@ public fun CharArray.sort(): Unit { */ @kotlin.internal.InlineOnly public inline fun > Array.sort(): Unit { + @Suppress("UNCHECKED_CAST") (this as Array).sort() } diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 6a3978e0380..0706f33ef88 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -255,6 +255,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") // false warning, extension takes precedence in some cases public fun <@kotlin.internal.OnlyInputTypes T> List.indexOf(element: T): Int { return indexOf(element) } @@ -355,6 +356,7 @@ public inline fun Iterable.last(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return last as T } @@ -389,6 +391,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") // false warning, extension takes precedence in some cases public fun <@kotlin.internal.OnlyInputTypes T> List.lastIndexOf(element: T): Int { return lastIndexOf(element) } @@ -486,6 +489,7 @@ public inline fun Iterable.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Collection contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 1e7fa7cb9da..1beb10ebc78 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -209,6 +209,7 @@ public inline fun Sequence.last(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return last as T } @@ -289,6 +290,7 @@ public inline fun Sequence.single(predicate: (T) -> Boolean): T { } } if (!found) throw NoSuchElementException("Sequence contains no element matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T } diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 06152dee391..ec9305b2bfb 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -189,6 +189,7 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char { } } if (!found) throw NoSuchElementException("Char sequence contains no character matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as Char } diff --git a/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt b/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt index 7f30b156c70..d5478f0628e 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt +++ b/libraries/stdlib/src/kotlin/collections/AbstractIterator.kt @@ -28,6 +28,7 @@ public abstract class AbstractIterator: Iterator { override fun next(): T { if (!hasNext()) throw NoSuchElementException() state = State.NotReady + @Suppress("UNCHECKED_CAST") return nextValue as T } diff --git a/libraries/stdlib/src/kotlin/collections/Collections.kt b/libraries/stdlib/src/kotlin/collections/Collections.kt index 77ba31809d1..e6daf7b4e46 100644 --- a/libraries/stdlib/src/kotlin/collections/Collections.kt +++ b/libraries/stdlib/src/kotlin/collections/Collections.kt @@ -173,6 +173,7 @@ public inline fun java.util.Enumeration.toList(): List = java.util.Col * * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection`. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases @kotlin.internal.InlineOnly public inline fun <@kotlin.internal.OnlyInputTypes T> Collection.containsAll(elements: Collection): Boolean = this.containsAll(elements) diff --git a/libraries/stdlib/src/kotlin/collections/Grouping.kt b/libraries/stdlib/src/kotlin/collections/Grouping.kt index b7234f4cd97..484bdec6b6f 100644 --- a/libraries/stdlib/src/kotlin/collections/Grouping.kt +++ b/libraries/stdlib/src/kotlin/collections/Grouping.kt @@ -97,6 +97,7 @@ public inline fun Grouping.fold( initialValueSelector: (key: K, element: T) -> R, operation: (key: K, accumulator: R, element: T) -> R ): Map = + @Suppress("UNCHECKED_CAST") aggregate { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) } /** @@ -126,6 +127,7 @@ public inline fun > Grouping.foldTo( initialValueSelector: (key: K, element: T) -> R, operation: (key: K, accumulator: R, element: T) -> R ): M = + @Suppress("UNCHECKED_CAST") aggregateTo(destination) { key, acc, e, first -> operation(key, if (first) initialValueSelector(key, e) else acc as R, e) } @@ -145,6 +147,7 @@ public inline fun Grouping.fold( initialValue: R, operation: (accumulator: R, element: T) -> R ): Map = + @Suppress("UNCHECKED_CAST") aggregate { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) } /** @@ -168,6 +171,7 @@ public inline fun > Grouping.foldTo( initialValue: R, operation: (accumulator: R, element: T) -> R ): M = + @Suppress("UNCHECKED_CAST") aggregateTo(destination) { _, acc, e, first -> operation(if (first) initialValue else acc as R, e) } @@ -190,6 +194,7 @@ public inline fun Grouping.reduce( operation: (key: K, accumulator: S, element: T) -> S ): Map = aggregate { key, acc, e, first -> + @Suppress("UNCHECKED_CAST") if (first) e else operation(key, acc as S, e) } @@ -216,6 +221,7 @@ public inline fun > Grouping.reduceTo operation: (key: K, accumulator: S, element: T) -> S ): M = aggregateTo(destination) { key, acc, e, first -> + @Suppress("UNCHECKED_CAST") if (first) e else operation(key, acc as S, e) } @@ -283,6 +289,7 @@ public inline fun > Grouping.eachSumOfTo(d @JvmVersion @PublishedApi @kotlin.internal.InlineOnly +@Suppress("UNCHECKED_CAST") // tricks with erased generics go here, do not repeat at reified platforms internal inline fun MutableMap.mapValuesInPlace(f: (Map.Entry) -> R): MutableMap { entries.forEach { (it as MutableMap.MutableEntry).setValue(f(it)) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index ef30c94e3f6..4f87c8129ba 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -175,6 +175,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`. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases @kotlin.internal.InlineOnly public inline fun Map.containsValue(value: V): Boolean = this.containsValue(value) @@ -235,6 +236,7 @@ internal inline fun Map.getOrElseNullable(key: K, defaultValue: () if (value == null && !containsKey(key)) { return defaultValue() } else { + @Suppress("UNCHECKED_CAST") return value as V } } diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt index 5a1ae81c045..db5d57281ca 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt +++ b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt @@ -48,11 +48,13 @@ public inline fun MutableList.remove(index: Int): T = removeAt(index) @Deprecated("Use sortWith(comparator) instead.", ReplaceWith("this.sortWith(comparator)"), level = DeprecationLevel.ERROR) @JvmVersion @kotlin.internal.InlineOnly +@Suppress("UNUSED_PARAMETER") public inline fun MutableList.sort(comparator: Comparator): Unit = throw NotImplementedError() @Deprecated("Use sortWith(Comparator(comparison)) instead.", ReplaceWith("this.sortWith(Comparator(comparison))"), level = DeprecationLevel.ERROR) @JvmVersion @kotlin.internal.InlineOnly +@Suppress("UNUSED_PARAMETER") public inline fun MutableList.sort(comparison: (T, T) -> Int): Unit = throw NotImplementedError() /** diff --git a/libraries/stdlib/src/kotlin/collections/Sequences.kt b/libraries/stdlib/src/kotlin/collections/Sequences.kt index 28537115b44..c14f143fba6 100644 --- a/libraries/stdlib/src/kotlin/collections/Sequences.kt +++ b/libraries/stdlib/src/kotlin/collections/Sequences.kt @@ -123,6 +123,7 @@ internal class FilteringSequence(private val sequence: Sequence, val result = nextItem nextItem = null nextState = -1 + @Suppress("UNCHECKED_CAST") return result as T } @@ -380,6 +381,7 @@ internal class TakeWhileSequence calcNext() // will change nextState if (nextState == 0) throw NoSuchElementException() + @Suppress("UNCHECKED_CAST") val result = nextItem as T // Clean next to avoid keeping reference on yielded instance @@ -466,6 +468,7 @@ internal class DropWhileSequence drop() if (dropState == 1) { + @Suppress("UNCHECKED_CAST") val result = nextItem as T nextItem = null dropState = 0 diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/CoroutinesLibrary.kt b/libraries/stdlib/src/kotlin/coroutines/experimental/CoroutinesLibrary.kt index de637eda5d8..291cececd31 100644 --- a/libraries/stdlib/src/kotlin/coroutines/experimental/CoroutinesLibrary.kt +++ b/libraries/stdlib/src/kotlin/coroutines/experimental/CoroutinesLibrary.kt @@ -100,6 +100,7 @@ internal inline fun processBareContinuationResume(completion: Continuation<*>, b try { val result = block() if (result !== COROUTINE_SUSPENDED) { + @Suppress("UNCHECKED_CAST") (completion as Continuation).resume(result) } } catch (t: Throwable) { diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/SequenceBuilder.kt b/libraries/stdlib/src/kotlin/coroutines/experimental/SequenceBuilder.kt index e8251d24fd7..32f2d304c8c 100644 --- a/libraries/stdlib/src/kotlin/coroutines/experimental/SequenceBuilder.kt +++ b/libraries/stdlib/src/kotlin/coroutines/experimental/SequenceBuilder.kt @@ -138,6 +138,7 @@ private class SequenceBuilderIterator : SequenceBuilder(), Iterator, Co } State_Ready -> { state = State_NotReady + @Suppress("UNCHECKED_CAST") val result = nextValue as T nextValue = null return result diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/Intrinsics.kt b/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/Intrinsics.kt index b463c9924bb..10a4dae9711 100644 --- a/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/Intrinsics.kt +++ b/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/Intrinsics.kt @@ -41,7 +41,9 @@ import kotlin.coroutines.experimental.processBareContinuationResume */ @SinceKotlin("1.1") @kotlin.internal.InlineOnly -public inline suspend fun suspendCoroutineOrReturn(crossinline block: (Continuation) -> Any?): T = null!! +@Suppress("UNUSED_PARAMETER") +public inline suspend fun suspendCoroutineOrReturn(crossinline block: (Continuation) -> Any?): T = + throw NotImplementedError("Implementation is intrinsic") /** * This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that @@ -69,6 +71,7 @@ public fun (suspend () -> T).createCoroutineUnchecked( ): Continuation = if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) buildContinuationByInvokeCall(completion) { + @Suppress("UNCHECKED_CAST") (this as Function1, Any?>).invoke(completion) } else @@ -92,6 +95,7 @@ public fun (suspend R.() -> T).createCoroutineUnchecked( ): Continuation = if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) buildContinuationByInvokeCall(completion) { + @Suppress("UNCHECKED_CAST") (this as Function2, Any?>).invoke(receiver, completion) } else diff --git a/libraries/stdlib/src/kotlin/io/files/Utils.kt b/libraries/stdlib/src/kotlin/io/files/Utils.kt index b9767b08e69..1870dc8ce7a 100644 --- a/libraries/stdlib/src/kotlin/io/files/Utils.kt +++ b/libraries/stdlib/src/kotlin/io/files/Utils.kt @@ -240,7 +240,7 @@ private class TerminateException(file: File) : FileSystemException(file) {} public fun File.copyRecursively(target: File, overwrite: Boolean = false, onError: (File, IOException) -> OnErrorAction = - { file, exception -> throw exception } + { _, exception -> throw exception } ): Boolean { if (!exists()) { return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) != diff --git a/libraries/stdlib/src/kotlin/text/Char.kt b/libraries/stdlib/src/kotlin/text/Char.kt index 51e0a922f01..ce762b916c3 100644 --- a/libraries/stdlib/src/kotlin/text/Char.kt +++ b/libraries/stdlib/src/kotlin/text/Char.kt @@ -36,11 +36,11 @@ 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 { - if (this === other) return true + if (this == other) return true if (!ignoreCase) return false - if (this.toUpperCase() === other.toUpperCase()) return true - if (this.toLowerCase() === other.toLowerCase()) return true + if (this.toUpperCase() == other.toUpperCase()) return true + if (this.toLowerCase() == other.toLowerCase()) return true return false } diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index 032d2d193b6..1b8d1f57d34 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -308,6 +308,7 @@ public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence * Replace parameter names with the same as those of [CharSequence.subSequence]. */ @kotlin.internal.InlineOnly +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning @Deprecated("Use parameters named startIndex and endIndex.", ReplaceWith("subSequence(startIndex = start, endIndex = end)")) public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSequence(start, end) diff --git a/libraries/stdlib/src/kotlin/util/Exceptions.kt b/libraries/stdlib/src/kotlin/util/Exceptions.kt index e17f1270610..f594600a432 100644 --- a/libraries/stdlib/src/kotlin/util/Exceptions.kt +++ b/libraries/stdlib/src/kotlin/util/Exceptions.kt @@ -11,18 +11,21 @@ import kotlin.internal.* /** * Prints the stack trace of this throwable to the standard output. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available @kotlin.internal.InlineOnly public inline fun Throwable.printStackTrace(): Unit = (this as java.lang.Throwable).printStackTrace() /** * Prints the stack trace of this throwable to the specified [writer]. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available @kotlin.internal.InlineOnly public inline fun Throwable.printStackTrace(writer: PrintWriter): Unit = (this as java.lang.Throwable).printStackTrace(writer) /** * Prints the stack trace of this throwable to the specified [stream]. */ +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // to be used when no member available @kotlin.internal.InlineOnly public inline fun Throwable.printStackTrace(stream: PrintStream): Unit = (this as java.lang.Throwable).printStackTrace(stream) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 59d26b58f64..902d94d4a90 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -33,6 +33,7 @@ fun elements(): List { only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists) doc { f -> "Returns first index of [element], or -1 if the ${f.collection} does not contain element." } typeParam("@kotlin.internal.OnlyInputTypes T") + annotations(Lists) { """@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases""" } returns("Int") body { f -> """ @@ -82,6 +83,7 @@ fun elements(): List { only(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Lists) doc { f -> "Returns last index of [element], or -1 if the ${f.collection} does not contain element." } typeParam("@kotlin.internal.OnlyInputTypes T") + annotations(Lists) { """@Suppress("EXTENSION_SHADOWED_BY_MEMBER") // false warning, extension takes precedence in some cases""" } returns("Int") body { f -> """ @@ -538,6 +540,7 @@ fun elements(): List { } } if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.") + @Suppress("UNCHECKED_CAST") return last as T """ } @@ -710,6 +713,7 @@ fun elements(): List { } } if (!found) throw NoSuchElementException("${f.doc.collection.capitalize()} contains no ${f.doc.element} matching the predicate.") + @Suppress("UNCHECKED_CAST") return single as T """ } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 44e34be8ab9..1f77104a390 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -426,7 +426,10 @@ object CommonArrays { returns("Unit") inline(Platform.JVM, Inline.Only) body(Platform.JVM) { - "(this as Array).sort()" + """ + @Suppress("UNCHECKED_CAST") + (this as Array).sort() + """ } body(Platform.JS) { """