Apply infix modifier on functions from stdlib where appropriate.
This commit is contained in:
@@ -528,4 +528,4 @@ fun merge(i1: InterfaceDefinition, i2: InterfaceDefinition): InterfaceDefinition
|
||||
)
|
||||
}
|
||||
|
||||
fun <T> List<T>.merge(other: List<T>) = (this + other).distinct().toList()
|
||||
infix fun <T> List<T>.merge(other: List<T>) = (this + other).distinct()
|
||||
|
||||
@@ -59,11 +59,9 @@ private fun String.replaceWrongConstants(type: Type) = when {
|
||||
private fun String.replaceKeywords() = if (this in keywords) this + "_" else this
|
||||
|
||||
private fun Appendable.renderArgumentsDeclaration(args: List<GenerateAttribute>, omitDefaults: Boolean = false) =
|
||||
args.map {
|
||||
StringBuilder {
|
||||
renderAttributeDeclaration(it, it.override, false, omitDefaults)
|
||||
}
|
||||
}.joinTo(this, ", ", "(", ")")
|
||||
args.joinTo(this, ", ", "(", ")") {
|
||||
StringBuilder().apply { renderAttributeDeclaration(it, it.override, false, omitDefaults) }
|
||||
}
|
||||
|
||||
private fun renderCall(call: GenerateFunctionCall) = "${call.name.replaceKeywords()}(${call.arguments.joinToString(", ") { it.replaceKeywords() }})"
|
||||
|
||||
|
||||
@@ -582,6 +582,7 @@ fun generators(): List<GenericFunction> {
|
||||
|
||||
|
||||
templates add f("zip(other: Iterable<R>)") {
|
||||
infix(true)
|
||||
exclude(Sequences)
|
||||
doc {
|
||||
"""
|
||||
@@ -598,6 +599,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("zip(other: String)") {
|
||||
infix(true)
|
||||
deprecate(Strings) { forBinaryCompatibility }
|
||||
only(CharSequences, Strings)
|
||||
doc {
|
||||
@@ -614,6 +616,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("zip(array: Array<out R>)") {
|
||||
infix(true)
|
||||
exclude(Sequences)
|
||||
doc {
|
||||
"""
|
||||
@@ -630,6 +633,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("zip(array: SELF)") {
|
||||
infix(true)
|
||||
only(ArraysOfPrimitives)
|
||||
doc {
|
||||
"""
|
||||
@@ -645,6 +649,7 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("zip(sequence: Sequence<R>)") {
|
||||
infix(true)
|
||||
only(Sequences)
|
||||
doc {
|
||||
"""
|
||||
|
||||
@@ -90,6 +90,7 @@ fun sets(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("union(other: Iterable<T>)") {
|
||||
infix(true)
|
||||
exclude(Strings, Sequences)
|
||||
doc { "Returns a set containing all distinct elements from both collections." }
|
||||
returns("Set<T>")
|
||||
@@ -103,6 +104,7 @@ fun sets(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("intersect(other: Iterable<T>)") {
|
||||
infix(true)
|
||||
exclude(Strings, Sequences)
|
||||
doc { "Returns a set containing all elements that are contained by both this set and the specified collection." }
|
||||
returns("Set<T>")
|
||||
@@ -116,6 +118,7 @@ fun sets(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("subtract(other: Iterable<T>)") {
|
||||
infix(true)
|
||||
exclude(Strings, Sequences)
|
||||
doc { "Returns a set containing all elements that are contained by this set and not contained by the specified collection." }
|
||||
returns("Set<T>")
|
||||
|
||||
Reference in New Issue
Block a user