Mark builtins and stblib functions with 'operator'
This commit is contained in:
@@ -6,6 +6,8 @@ fun elements(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("contains(element: T)") {
|
||||
operator(true)
|
||||
|
||||
doc { "Returns `true` if [element] is found in the collection." }
|
||||
returns("Boolean")
|
||||
body {
|
||||
@@ -761,6 +763,7 @@ fun elements(): List<GenericFunction> {
|
||||
|
||||
templates addAll (1..5).map { n ->
|
||||
f("component$n()") {
|
||||
operator(true)
|
||||
inline(true)
|
||||
annotations("""@Suppress("NOTHING_TO_INLINE")""")
|
||||
fun getOrdinal(n: Int) = n.toString() + when (n) {
|
||||
|
||||
@@ -105,6 +105,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
|
||||
val inline = FamilyProperty<Boolean>()
|
||||
val typeParams = ArrayList<String>()
|
||||
val returns = FamilyProperty<String>()
|
||||
val operator = FamilyProperty<Boolean>()
|
||||
val body = object : FamilyProperty<String>() {
|
||||
override fun onKeySet(key: Family) = include(key)
|
||||
}
|
||||
@@ -335,6 +336,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
|
||||
builder.append("public ")
|
||||
if (inline[f] == true)
|
||||
builder.append("inline ")
|
||||
if (operator[f] == true)
|
||||
builder.append("operator ")
|
||||
|
||||
builder.append("$keyword ")
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ fun generators(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("plus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Collections, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection and then the given [element]." }
|
||||
returns("List<T>")
|
||||
@@ -49,6 +51,8 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("plus(collection: Iterable<T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Collections, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection and then all elements of the given [collection]." }
|
||||
returns("List<T>")
|
||||
@@ -104,6 +108,8 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("plus(array: Array<out T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Collections, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection and then all elements of the given [array]." }
|
||||
returns("List<T>")
|
||||
@@ -151,6 +157,8 @@ fun generators(): List<GenericFunction> {
|
||||
|
||||
|
||||
templates add f("plus(sequence: Sequence<T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection and then all elements of the given [sequence]." }
|
||||
returns("List<T>")
|
||||
@@ -199,6 +207,8 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("minus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection without the first occurrence of the given [element]." }
|
||||
returns("List<T>")
|
||||
@@ -236,6 +246,8 @@ fun generators(): List<GenericFunction> {
|
||||
|
||||
|
||||
templates add f("minus(collection: Iterable<T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [collection]." }
|
||||
returns("List<T>")
|
||||
@@ -289,6 +301,8 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("minus(array: Array<out T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sets, Sequences)
|
||||
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [array]." }
|
||||
returns("List<T>")
|
||||
@@ -331,6 +345,8 @@ fun generators(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("minus(sequence: Sequence<T>)") {
|
||||
operator(true)
|
||||
|
||||
only(Iterables, Sets)
|
||||
doc { "Returns a list containing all elements of the original collection except the elements contained in the given [sequence]." }
|
||||
returns("List<T>")
|
||||
|
||||
@@ -118,6 +118,8 @@ fun ranges(): List<GenericFunction> {
|
||||
.map { until(it.first, it.second) }
|
||||
|
||||
fun contains(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") {
|
||||
operator(true)
|
||||
|
||||
val meaningless = (rangeType.isNumeric() != itemType.isNumeric())
|
||||
if (!meaningless) {
|
||||
only(Ranges)
|
||||
|
||||
@@ -6,6 +6,8 @@ fun specialJVM(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("plus(element: T)") {
|
||||
operator(true)
|
||||
|
||||
only(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
returns("SELF")
|
||||
doc { "Returns an array containing all elements of the original array and then the given [element]." }
|
||||
@@ -20,6 +22,8 @@ fun specialJVM(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("plus(collection: Collection<T>)") {
|
||||
operator(true)
|
||||
|
||||
only(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
returns("SELF")
|
||||
doc { "Returns an array containing all elements of the original array and then all elements of the given [collection]." }
|
||||
@@ -34,6 +38,8 @@ fun specialJVM(): List<GenericFunction> {
|
||||
}
|
||||
|
||||
templates add f("plus(array: SELF)") {
|
||||
operator(true)
|
||||
|
||||
only(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
customSignature(InvariantArraysOfObjects) { "plus(array: Array<out T>)" }
|
||||
doc { "Returns an array containing all elements of the original array and then all elements of the given [array]." }
|
||||
|
||||
Reference in New Issue
Block a user