Suppress expect-actual mismatch for relaxed array extensions

Due to KT-21937
This commit is contained in:
Ilya Gorbunov
2018-01-25 18:04:59 +03:00
parent 38be99daa3
commit 912c69aaa3
3 changed files with 56 additions and 5 deletions
@@ -5570,6 +5570,7 @@ public expect fun CharArray.contentToString(): String
/**
* Returns new array which is a copy of the original array.
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect fun <T> Array<T>.copyOf(): Array<T>
/**
@@ -5655,11 +5656,13 @@ public expect fun CharArray.copyOf(newSize: Int): CharArray
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect fun <T> Array<T>.copyOf(newSize: Int): Array<T?>
/**
* Returns new array which is a copy of range of original array.
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
/**
@@ -5957,6 +5960,7 @@ public val CharArray.lastIndex: Int
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect operator fun <T> Array<T>.plus(element: T): Array<T>
/**
@@ -6002,6 +6006,7 @@ public expect operator fun CharArray.plus(element: Char): CharArray
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect operator fun <T> Array<T>.plus(elements: Collection<T>): Array<T>
/**
@@ -6047,6 +6052,7 @@ public expect operator fun CharArray.plus(elements: Collection<Char>): CharArray
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect operator fun <T> Array<T>.plus(elements: Array<out T>): Array<T>
/**
@@ -6092,6 +6098,7 @@ public expect operator fun CharArray.plus(elements: CharArray): CharArray
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
public expect fun <T> Array<T>.plusElement(element: T): Array<T>
/**
@@ -415,7 +415,7 @@ public actual fun CharArray.contentToString(): String {
/**
* Returns new array which is a copy of the original array.
*/
@Suppress("NOTHING_TO_INLINE")
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline fun <T> Array<out T>.copyOf(): Array<T> {
return this.asDynamic().slice()
}
@@ -540,6 +540,7 @@ public actual fun CharArray.copyOf(newSize: Int): CharArray {
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
return arrayCopyResize(this, newSize, null)
}
@@ -547,7 +548,7 @@ public actual fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
/**
* Returns new array which is a copy of range of original array.
*/
@Suppress("NOTHING_TO_INLINE")
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
return this.asDynamic().slice(fromIndex, toIndex)
}
@@ -616,7 +617,7 @@ public actual fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline operator fun <T> Array<out T>.plus(element: T): Array<T> {
return this.asDynamic().concat(arrayOf(element))
}
@@ -688,6 +689,7 @@ public actual inline operator fun CharArray.plus(element: Char): CharArray {
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual operator fun <T> Array<out T>.plus(elements: Collection<T>): Array<T> {
return arrayPlusCollection(this, elements)
}
@@ -751,7 +753,7 @@ public actual operator fun CharArray.plus(elements: Collection<Char>): CharArray
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline operator fun <T> Array<out T>.plus(elements: Array<out T>): Array<T> {
return this.asDynamic().concat(elements)
}
@@ -823,7 +825,7 @@ public actual inline operator fun CharArray.plus(elements: CharArray): CharArray
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline fun <T> Array<out T>.plusElement(element: T): Array<T> {
return this.asDynamic().concat(arrayOf(element))
}
@@ -249,6 +249,7 @@ object ArrayOps : TemplateGroupBase() {
on(Platform.JS) {
family = ArraysOfObjects
inline(suppressWarning = true)
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
returns("Array<T>")
body {
"""
@@ -256,6 +257,11 @@ object ArrayOps : TemplateGroupBase() {
"""
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
val f_plus = fn("plus(element: T)") {
@@ -280,6 +286,7 @@ object ArrayOps : TemplateGroupBase() {
inline(suppressWarning = true)
specialFor(InvariantArraysOfObjects) {
family = ArraysOfObjects
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
returns("Array<T>")
}
@@ -290,6 +297,11 @@ object ArrayOps : TemplateGroupBase() {
"return plus(${primitive.name.toLowerCase()}ArrayOf(element))"
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
@@ -315,6 +327,7 @@ object ArrayOps : TemplateGroupBase() {
// annotations(Platform.JS, """@Suppress("NOTHING_TO_INLINE")""")
specialFor(InvariantArraysOfObjects) {
family = ArraysOfObjects
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
returns("Array<T>")
}
when (primitive) {
@@ -324,6 +337,11 @@ object ArrayOps : TemplateGroupBase() {
body { "return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)" }
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
val f_plus_array = fn("plus(elements: SELF)") {
@@ -352,6 +370,7 @@ object ArrayOps : TemplateGroupBase() {
inline(suppressWarning = true)
specialFor(InvariantArraysOfObjects) {
family = ArraysOfObjects
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
returns("Array<T>")
body { """return this.asDynamic().concat(elements)""" }
}
@@ -359,6 +378,11 @@ object ArrayOps : TemplateGroupBase() {
body { """return primitiveArrayConcat(this, elements)""" }
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
@@ -371,6 +395,7 @@ object ArrayOps : TemplateGroupBase() {
on(Platform.JS) {
specialFor(InvariantArraysOfObjects) {
family = ArraysOfObjects
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
returns("Array<T>")
}
when(primitive) {
@@ -386,6 +411,11 @@ object ArrayOps : TemplateGroupBase() {
inlineOnly()
body { "return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)" }
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
val f_copyOf = fn("copyOf()") {
@@ -402,6 +432,7 @@ object ArrayOps : TemplateGroupBase() {
specialFor(InvariantArraysOfObjects) {
family = ArraysOfObjects
returns("Array<T>")
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
}
when (primitive) {
null -> {
@@ -416,6 +447,11 @@ object ArrayOps : TemplateGroupBase() {
}
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
val f_copyOf_newSize = fn("copyOf(newSize: Int)") {
@@ -443,6 +479,7 @@ object ArrayOps : TemplateGroupBase() {
returns("Array<T?>")
on(Platform.JS) {
family = ArraysOfObjects
suppress("ACTUAL_WITHOUT_EXPECT") // TODO: KT-21937
body { "return arrayCopyResize(this, newSize, null)" }
}
}
@@ -452,6 +489,11 @@ object ArrayOps : TemplateGroupBase() {
"return java.util.Arrays.copyOf(this, newSize)"
}
}
on(Platform.Common) {
specialFor(InvariantArraysOfObjects) {
suppress("NO_ACTUAL_FOR_EXPECT") // TODO: KT-21937
}
}
}
val f_sort = fn("sort()") {