Introduce plusElement and minusElement to disambiguate situations like List<List<T>> + List<T>
#KT-9992 Fixed
This commit is contained in:
@@ -5,6 +5,17 @@ import templates.Family.*
|
||||
fun generators(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("plusElement(element: T)") {
|
||||
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]." }
|
||||
doc(Sequences) { "Returns a sequence containing all elements of the original sequence and then the given [element]." }
|
||||
|
||||
returns("List<T>")
|
||||
returns("SELF", Sets, Sequences)
|
||||
body { "return plus(element)" }
|
||||
}
|
||||
|
||||
templates add f("plus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
@@ -206,6 +217,17 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("minusElement(element: T)") {
|
||||
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]." }
|
||||
doc(Sequences) { "Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]." }
|
||||
|
||||
returns("List<T>")
|
||||
returns("SELF", Sets, Sequences)
|
||||
body { "return minus(element)" }
|
||||
}
|
||||
|
||||
templates add f("minus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
|
||||
@@ -90,6 +90,20 @@ fun specialJS(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
|
||||
templates add f("plusElement(element: T)") {
|
||||
only(ArraysOfObjects)
|
||||
returns("SELF")
|
||||
returns(ArraysOfObjects) { "Array<T>" }
|
||||
inline(true)
|
||||
annotations("""@Suppress("NOTHING_TO_INLINE")""")
|
||||
doc { "Returns an array containing all elements of the original array and then the given [element]." }
|
||||
body() {
|
||||
"""
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("plus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
|
||||
@@ -5,6 +5,13 @@ import templates.Family.*
|
||||
fun specialJVM(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("plusElement(element: T)") {
|
||||
only(InvariantArraysOfObjects)
|
||||
returns("SELF")
|
||||
doc { "Returns an array containing all elements of the original array and then the given [element]." }
|
||||
body { "return plus(element)" }
|
||||
}
|
||||
|
||||
templates add f("plus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user