diff --git a/core/builtins/native/kotlin/Any.kt b/core/builtins/native/kotlin/Any.kt index 228b17713d2..15ff8501018 100644 --- a/core/builtins/native/kotlin/Any.kt +++ b/core/builtins/native/kotlin/Any.kt @@ -32,7 +32,7 @@ public open class Any { * Note that the `==` operator in Kotlin code is translated into a call to [equals] when objects on both sides of the * operator are not null. */ - public open fun equals(other: Any?): Boolean + public open operator fun equals(other: Any?): Boolean /** * Returns a hash code value for the object. The general contract of hashCode is: diff --git a/core/builtins/native/kotlin/Array.kt b/core/builtins/native/kotlin/Array.kt index d84ec5c9d4b..ed6ba662ec1 100644 --- a/core/builtins/native/kotlin/Array.kt +++ b/core/builtins/native/kotlin/Array.kt @@ -31,7 +31,7 @@ public class Array private (): Cloneable { * value = arr[index] * ``` */ - public fun get(index: Int): T + public operator fun get(index: Int): T /** * Sets the array element at the specified [index] to the specified [value]. This method can @@ -40,7 +40,7 @@ public class Array private (): Cloneable { * arr[index] = value * ``` */ - public fun set(index: Int, value: T): Unit + public operator fun set(index: Int, value: T): Unit /** * Returns the number of elements in the array. @@ -50,7 +50,7 @@ public class Array private (): Cloneable { /** * Creates an iterator for iterating over the elements of the array. */ - public fun iterator(): Iterator + public operator fun iterator(): Iterator /** * Creates a shallow copy of the array. diff --git a/core/builtins/native/kotlin/Arrays.kt b/core/builtins/native/kotlin/Arrays.kt index 90d1f0f4b42..953b77ef4db 100644 --- a/core/builtins/native/kotlin/Arrays.kt +++ b/core/builtins/native/kotlin/Arrays.kt @@ -24,15 +24,15 @@ package kotlin */ public class ByteArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Byte + public operator fun get(index: Int): Byte /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Byte): Unit + public operator fun set(index: Int, value: Byte): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): ByteIterator + public operator fun iterator(): ByteIterator public override fun clone(): ByteArray } @@ -43,15 +43,15 @@ public class ByteArray(size: Int) : Cloneable { */ public class CharArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Char + public operator fun get(index: Int): Char /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Char): Unit + public operator fun set(index: Int, value: Char): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): CharIterator + public operator fun iterator(): CharIterator public override fun clone(): CharArray } @@ -62,15 +62,15 @@ public class CharArray(size: Int) : Cloneable { */ public class ShortArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Short + public operator fun get(index: Int): Short /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Short): Unit + public operator fun set(index: Int, value: Short): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): ShortIterator + public operator fun iterator(): ShortIterator public override fun clone(): ShortArray } @@ -81,15 +81,15 @@ public class ShortArray(size: Int) : Cloneable { */ public class IntArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Int + public operator fun get(index: Int): Int /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Int): Unit + public operator fun set(index: Int, value: Int): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): IntIterator + public operator fun iterator(): IntIterator public override fun clone(): IntArray } @@ -100,15 +100,15 @@ public class IntArray(size: Int) : Cloneable { */ public class LongArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Long + public operator fun get(index: Int): Long /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Long): Unit + public operator fun set(index: Int, value: Long): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): LongIterator + public operator fun iterator(): LongIterator public override fun clone(): LongArray } @@ -119,15 +119,15 @@ public class LongArray(size: Int) : Cloneable { */ public class FloatArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Float + public operator fun get(index: Int): Float /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Float): Unit + public operator fun set(index: Int, value: Float): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): FloatIterator + public operator fun iterator(): FloatIterator public override fun clone(): FloatArray } @@ -138,15 +138,15 @@ public class FloatArray(size: Int) : Cloneable { */ public class DoubleArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Double + public operator fun get(index: Int): Double /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Double): Unit + public operator fun set(index: Int, value: Double): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): DoubleIterator + public operator fun iterator(): DoubleIterator public override fun clone(): DoubleArray } @@ -157,15 +157,15 @@ public class DoubleArray(size: Int) : Cloneable { */ public class BooleanArray(size: Int) : Cloneable { /** Returns the array element at the given [index]. This method can be called using the index operator. */ - public fun get(index: Int): Boolean + public operator fun get(index: Int): Boolean /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ - public fun set(index: Int, value: Boolean): Unit + public operator fun set(index: Int, value: Boolean): Unit /** Returns the number of elements in the array. */ public fun size(): Int /** Creates an iterator over the elements of the array. */ - public fun iterator(): BooleanIterator + public operator fun iterator(): BooleanIterator public override fun clone(): BooleanArray } diff --git a/core/builtins/native/kotlin/Boolean.kt b/core/builtins/native/kotlin/Boolean.kt index 4dde62d2b01..578f2770cad 100644 --- a/core/builtins/native/kotlin/Boolean.kt +++ b/core/builtins/native/kotlin/Boolean.kt @@ -24,7 +24,7 @@ public class Boolean private () : Comparable { /** * Returns the inverse of this boolean. */ - public fun not(): Boolean + public operator fun not(): Boolean /** * Performs a logical `and` operation between this Boolean and the [other] one. diff --git a/core/builtins/native/kotlin/Char.kt b/core/builtins/native/kotlin/Char.kt index 140094a91d3..329663908b8 100644 --- a/core/builtins/native/kotlin/Char.kt +++ b/core/builtins/native/kotlin/Char.kt @@ -31,20 +31,20 @@ public class Char private () : Comparable { public override fun compareTo(other: Char): Int /** Adds the other Int value to this value resulting a Char. */ - public fun plus(other: Int): Char + public operator fun plus(other: Int): Char /** Subtracts the other Char value from this value resulting an Int. */ - public fun minus(other: Char): Int + public operator fun minus(other: Char): Int /** Subtracts the other Int value from this value resulting a Char. */ - public fun minus(other: Int): Char + public operator fun minus(other: Int): Char /** Increments this value. */ - public fun inc(): Char + public operator fun inc(): Char /** Decrements this value. */ - public fun dec(): Char + public operator fun dec(): Char /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Char): CharRange + public operator fun rangeTo(other: Char): CharRange /** Returns the value of this character as a `Byte`. */ public override fun toByte(): Byte diff --git a/core/builtins/native/kotlin/Collections.kt b/core/builtins/native/kotlin/Collections.kt index 43516037603..522481c5d1b 100644 --- a/core/builtins/native/kotlin/Collections.kt +++ b/core/builtins/native/kotlin/Collections.kt @@ -25,7 +25,7 @@ public interface Iterable { /** * Returns an iterator over the elements of this object. */ - public fun iterator(): Iterator + public operator fun iterator(): Iterator } /** @@ -59,7 +59,7 @@ public interface Collection : Iterable { /** * Checks if the specified element is contained in this collection. */ - public fun contains(o: Any?): Boolean + public operator fun contains(o: Any?): Boolean override fun iterator(): Iterator // Bulk Operations @@ -140,7 +140,7 @@ public interface List : Collection { /** * Returns the element at the specified index in the list. */ - public fun get(index: Int): E + public operator fun get(index: Int): E // Search Operations /** @@ -202,7 +202,7 @@ public interface MutableList : List, MutableCollection { * * @return the element previously at the specified position. */ - public fun set(index: Int, element: E): E + public operator fun set(index: Int, element: E): E /** * Inserts an element into the list at the specified [index]. @@ -294,7 +294,7 @@ public interface Map { /** * Returns the value corresponding to the given [key], or `null` if such a key is not present in the map. */ - public fun get(key: Any?): V? + public operator fun get(key: Any?): V? // Views /** diff --git a/core/builtins/native/kotlin/Comparable.kt b/core/builtins/native/kotlin/Comparable.kt index 0fffb68bc14..bcc2bf337c9 100644 --- a/core/builtins/native/kotlin/Comparable.kt +++ b/core/builtins/native/kotlin/Comparable.kt @@ -25,5 +25,5 @@ public interface Comparable { * to the specified [other] object, a negative number if it's less than [other], or a positive number * if it's greater than [other]. */ - public fun compareTo(other: T): Int + public operator fun compareTo(other: T): Int } diff --git a/core/builtins/native/kotlin/Iterator.kt b/core/builtins/native/kotlin/Iterator.kt index 8f6d2f0662c..0359d6c3967 100644 --- a/core/builtins/native/kotlin/Iterator.kt +++ b/core/builtins/native/kotlin/Iterator.kt @@ -24,12 +24,12 @@ public interface Iterator { /** * Returns the next element in the iteration. */ - public fun next(): T + public operator fun next(): T /** * Returns `true` if the iteration has more elements. */ - public fun hasNext(): Boolean + public operator fun hasNext(): Boolean } /** diff --git a/core/builtins/native/kotlin/Library.kt b/core/builtins/native/kotlin/Library.kt index fc8b3d1ee75..5a8391722f9 100644 --- a/core/builtins/native/kotlin/Library.kt +++ b/core/builtins/native/kotlin/Library.kt @@ -32,7 +32,7 @@ public fun Any?.toString(): String * Concatenates this string with the string representation of the given [other] object. If either the receiver * or the [other] object are null, they are represented as the string "null". */ -public fun String?.plus(other: Any?): String +public operator fun String?.plus(other: Any?): String /** * Returns an array of objects of the given type with the given [size], initialized with null values. diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index c0f93d7577f..5b1e542de7b 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -30,124 +30,124 @@ public class Byte private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Byte): Int + public override operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Short): Int + public operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Int): Int + public operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Long): Int + public operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Float): Int + public operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Double): Int + public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Int + public operator fun plus(other: Byte): Int /** Adds the other value to this value. */ - public fun plus(other: Short): Int + public operator fun plus(other: Short): Int /** Adds the other value to this value. */ - public fun plus(other: Int): Int + public operator fun plus(other: Int): Int /** Adds the other value to this value. */ - public fun plus(other: Long): Long + public operator fun plus(other: Long): Long /** Adds the other value to this value. */ - public fun plus(other: Float): Float + public operator fun plus(other: Float): Float /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Int + public operator fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - public fun minus(other: Short): Int + public operator fun minus(other: Short): Int /** Subtracts the other value from this value. */ - public fun minus(other: Int): Int + public operator fun minus(other: Int): Int /** Subtracts the other value from this value. */ - public fun minus(other: Long): Long + public operator fun minus(other: Long): Long /** Subtracts the other value from this value. */ - public fun minus(other: Float): Float + public operator fun minus(other: Float): Float /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Int + public operator fun times(other: Byte): Int /** Multiplies this value by the other value. */ - public fun times(other: Short): Int + public operator fun times(other: Short): Int /** Multiplies this value by the other value. */ - public fun times(other: Int): Int + public operator fun times(other: Int): Int /** Multiplies this value by the other value. */ - public fun times(other: Long): Long + public operator fun times(other: Long): Long /** Multiplies this value by the other value. */ - public fun times(other: Float): Float + public operator fun times(other: Float): Float /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Int + public operator fun div(other: Byte): Int /** Divides this value by the other value. */ - public fun div(other: Short): Int + public operator fun div(other: Short): Int /** Divides this value by the other value. */ - public fun div(other: Int): Int + public operator fun div(other: Int): Int /** Divides this value by the other value. */ - public fun div(other: Long): Long + public operator fun div(other: Long): Long /** Divides this value by the other value. */ - public fun div(other: Float): Float + public operator fun div(other: Float): Float /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Int + public operator fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Int + public operator fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Int + public operator fun mod(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Long + public operator fun mod(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Float + public operator fun mod(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Byte + public operator fun inc(): Byte /** Decrements this value. */ - public fun dec(): Byte + public operator fun dec(): Byte /** Returns this value. */ - public fun plus(): Int + public operator fun plus(): Int /** Returns the negative of this value. */ - public fun minus(): Int + public operator fun minus(): Int /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): ByteRange + public operator fun rangeTo(other: Byte): ByteRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): ShortRange + public operator fun rangeTo(other: Short): ShortRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): IntRange + public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): LongRange + public operator fun rangeTo(other: Long): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): FloatRange + public operator fun rangeTo(other: Float): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -170,124 +170,124 @@ public class Short private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Byte): Int + public operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Short): Int + public override operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Int): Int + public operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Long): Int + public operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Float): Int + public operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Double): Int + public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Int + public operator fun plus(other: Byte): Int /** Adds the other value to this value. */ - public fun plus(other: Short): Int + public operator fun plus(other: Short): Int /** Adds the other value to this value. */ - public fun plus(other: Int): Int + public operator fun plus(other: Int): Int /** Adds the other value to this value. */ - public fun plus(other: Long): Long + public operator fun plus(other: Long): Long /** Adds the other value to this value. */ - public fun plus(other: Float): Float + public operator fun plus(other: Float): Float /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Int + public operator fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - public fun minus(other: Short): Int + public operator fun minus(other: Short): Int /** Subtracts the other value from this value. */ - public fun minus(other: Int): Int + public operator fun minus(other: Int): Int /** Subtracts the other value from this value. */ - public fun minus(other: Long): Long + public operator fun minus(other: Long): Long /** Subtracts the other value from this value. */ - public fun minus(other: Float): Float + public operator fun minus(other: Float): Float /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Int + public operator fun times(other: Byte): Int /** Multiplies this value by the other value. */ - public fun times(other: Short): Int + public operator fun times(other: Short): Int /** Multiplies this value by the other value. */ - public fun times(other: Int): Int + public operator fun times(other: Int): Int /** Multiplies this value by the other value. */ - public fun times(other: Long): Long + public operator fun times(other: Long): Long /** Multiplies this value by the other value. */ - public fun times(other: Float): Float + public operator fun times(other: Float): Float /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Int + public operator fun div(other: Byte): Int /** Divides this value by the other value. */ - public fun div(other: Short): Int + public operator fun div(other: Short): Int /** Divides this value by the other value. */ - public fun div(other: Int): Int + public operator fun div(other: Int): Int /** Divides this value by the other value. */ - public fun div(other: Long): Long + public operator fun div(other: Long): Long /** Divides this value by the other value. */ - public fun div(other: Float): Float + public operator fun div(other: Float): Float /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Int + public operator fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Int + public operator fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Int + public operator fun mod(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Long + public operator fun mod(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Float + public operator fun mod(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Short + public operator fun inc(): Short /** Decrements this value. */ - public fun dec(): Short + public operator fun dec(): Short /** Returns this value. */ - public fun plus(): Int + public operator fun plus(): Int /** Returns the negative of this value. */ - public fun minus(): Int + public operator fun minus(): Int /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): ShortRange + public operator fun rangeTo(other: Byte): ShortRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): ShortRange + public operator fun rangeTo(other: Short): ShortRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): IntRange + public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): LongRange + public operator fun rangeTo(other: Long): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): FloatRange + public operator fun rangeTo(other: Float): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -310,124 +310,124 @@ public class Int private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Byte): Int + public operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Short): Int + public operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Int): Int + public override operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Long): Int + public operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Float): Int + public operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Double): Int + public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Int + public operator fun plus(other: Byte): Int /** Adds the other value to this value. */ - public fun plus(other: Short): Int + public operator fun plus(other: Short): Int /** Adds the other value to this value. */ - public fun plus(other: Int): Int + public operator fun plus(other: Int): Int /** Adds the other value to this value. */ - public fun plus(other: Long): Long + public operator fun plus(other: Long): Long /** Adds the other value to this value. */ - public fun plus(other: Float): Float + public operator fun plus(other: Float): Float /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Int + public operator fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - public fun minus(other: Short): Int + public operator fun minus(other: Short): Int /** Subtracts the other value from this value. */ - public fun minus(other: Int): Int + public operator fun minus(other: Int): Int /** Subtracts the other value from this value. */ - public fun minus(other: Long): Long + public operator fun minus(other: Long): Long /** Subtracts the other value from this value. */ - public fun minus(other: Float): Float + public operator fun minus(other: Float): Float /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Int + public operator fun times(other: Byte): Int /** Multiplies this value by the other value. */ - public fun times(other: Short): Int + public operator fun times(other: Short): Int /** Multiplies this value by the other value. */ - public fun times(other: Int): Int + public operator fun times(other: Int): Int /** Multiplies this value by the other value. */ - public fun times(other: Long): Long + public operator fun times(other: Long): Long /** Multiplies this value by the other value. */ - public fun times(other: Float): Float + public operator fun times(other: Float): Float /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Int + public operator fun div(other: Byte): Int /** Divides this value by the other value. */ - public fun div(other: Short): Int + public operator fun div(other: Short): Int /** Divides this value by the other value. */ - public fun div(other: Int): Int + public operator fun div(other: Int): Int /** Divides this value by the other value. */ - public fun div(other: Long): Long + public operator fun div(other: Long): Long /** Divides this value by the other value. */ - public fun div(other: Float): Float + public operator fun div(other: Float): Float /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Int + public operator fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Int + public operator fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Int + public operator fun mod(other: Int): Int /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Long + public operator fun mod(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Float + public operator fun mod(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Int + public operator fun inc(): Int /** Decrements this value. */ - public fun dec(): Int + public operator fun dec(): Int /** Returns this value. */ - public fun plus(): Int + public operator fun plus(): Int /** Returns the negative of this value. */ - public fun minus(): Int + public operator fun minus(): Int /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): IntRange + public operator fun rangeTo(other: Byte): IntRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): IntRange + public operator fun rangeTo(other: Short): IntRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): IntRange + public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): LongRange + public operator fun rangeTo(other: Long): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): FloatRange + public operator fun rangeTo(other: Float): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange /** Shifts this value left by [bits]. */ public fun shl(bits: Int): Int @@ -465,124 +465,124 @@ public class Long private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Byte): Int + public operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Short): Int + public operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Int): Int + public operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Long): Int + public override operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Float): Int + public operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Double): Int + public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Long + public operator fun plus(other: Byte): Long /** Adds the other value to this value. */ - public fun plus(other: Short): Long + public operator fun plus(other: Short): Long /** Adds the other value to this value. */ - public fun plus(other: Int): Long + public operator fun plus(other: Int): Long /** Adds the other value to this value. */ - public fun plus(other: Long): Long + public operator fun plus(other: Long): Long /** Adds the other value to this value. */ - public fun plus(other: Float): Float + public operator fun plus(other: Float): Float /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Long + public operator fun minus(other: Byte): Long /** Subtracts the other value from this value. */ - public fun minus(other: Short): Long + public operator fun minus(other: Short): Long /** Subtracts the other value from this value. */ - public fun minus(other: Int): Long + public operator fun minus(other: Int): Long /** Subtracts the other value from this value. */ - public fun minus(other: Long): Long + public operator fun minus(other: Long): Long /** Subtracts the other value from this value. */ - public fun minus(other: Float): Float + public operator fun minus(other: Float): Float /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Long + public operator fun times(other: Byte): Long /** Multiplies this value by the other value. */ - public fun times(other: Short): Long + public operator fun times(other: Short): Long /** Multiplies this value by the other value. */ - public fun times(other: Int): Long + public operator fun times(other: Int): Long /** Multiplies this value by the other value. */ - public fun times(other: Long): Long + public operator fun times(other: Long): Long /** Multiplies this value by the other value. */ - public fun times(other: Float): Float + public operator fun times(other: Float): Float /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Long + public operator fun div(other: Byte): Long /** Divides this value by the other value. */ - public fun div(other: Short): Long + public operator fun div(other: Short): Long /** Divides this value by the other value. */ - public fun div(other: Int): Long + public operator fun div(other: Int): Long /** Divides this value by the other value. */ - public fun div(other: Long): Long + public operator fun div(other: Long): Long /** Divides this value by the other value. */ - public fun div(other: Float): Float + public operator fun div(other: Float): Float /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Long + public operator fun mod(other: Byte): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Long + public operator fun mod(other: Short): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Long + public operator fun mod(other: Int): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Long + public operator fun mod(other: Long): Long /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Float + public operator fun mod(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Long + public operator fun inc(): Long /** Decrements this value. */ - public fun dec(): Long + public operator fun dec(): Long /** Returns this value. */ - public fun plus(): Long + public operator fun plus(): Long /** Returns the negative of this value. */ - public fun minus(): Long + public operator fun minus(): Long /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): LongRange + public operator fun rangeTo(other: Byte): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): LongRange + public operator fun rangeTo(other: Short): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): LongRange + public operator fun rangeTo(other: Int): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): LongRange + public operator fun rangeTo(other: Long): LongRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): FloatRange + public operator fun rangeTo(other: Float): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange /** Shifts this value left by [bits]. */ public fun shl(bits: Int): Long @@ -620,124 +620,124 @@ public class Float private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Byte): Int + public operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Short): Int + public operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Int): Int + public operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Long): Int + public operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Float): Int + public override operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Double): Int + public operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Float + public operator fun plus(other: Byte): Float /** Adds the other value to this value. */ - public fun plus(other: Short): Float + public operator fun plus(other: Short): Float /** Adds the other value to this value. */ - public fun plus(other: Int): Float + public operator fun plus(other: Int): Float /** Adds the other value to this value. */ - public fun plus(other: Long): Float + public operator fun plus(other: Long): Float /** Adds the other value to this value. */ - public fun plus(other: Float): Float + public operator fun plus(other: Float): Float /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Float + public operator fun minus(other: Byte): Float /** Subtracts the other value from this value. */ - public fun minus(other: Short): Float + public operator fun minus(other: Short): Float /** Subtracts the other value from this value. */ - public fun minus(other: Int): Float + public operator fun minus(other: Int): Float /** Subtracts the other value from this value. */ - public fun minus(other: Long): Float + public operator fun minus(other: Long): Float /** Subtracts the other value from this value. */ - public fun minus(other: Float): Float + public operator fun minus(other: Float): Float /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Float + public operator fun times(other: Byte): Float /** Multiplies this value by the other value. */ - public fun times(other: Short): Float + public operator fun times(other: Short): Float /** Multiplies this value by the other value. */ - public fun times(other: Int): Float + public operator fun times(other: Int): Float /** Multiplies this value by the other value. */ - public fun times(other: Long): Float + public operator fun times(other: Long): Float /** Multiplies this value by the other value. */ - public fun times(other: Float): Float + public operator fun times(other: Float): Float /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Float + public operator fun div(other: Byte): Float /** Divides this value by the other value. */ - public fun div(other: Short): Float + public operator fun div(other: Short): Float /** Divides this value by the other value. */ - public fun div(other: Int): Float + public operator fun div(other: Int): Float /** Divides this value by the other value. */ - public fun div(other: Long): Float + public operator fun div(other: Long): Float /** Divides this value by the other value. */ - public fun div(other: Float): Float + public operator fun div(other: Float): Float /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Float + public operator fun mod(other: Byte): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Float + public operator fun mod(other: Short): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Float + public operator fun mod(other: Int): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Float + public operator fun mod(other: Long): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Float + public operator fun mod(other: Float): Float /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Float + public operator fun inc(): Float /** Decrements this value. */ - public fun dec(): Float + public operator fun dec(): Float /** Returns this value. */ - public fun plus(): Float + public operator fun plus(): Float /** Returns the negative of this value. */ - public fun minus(): Float + public operator fun minus(): Float /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): FloatRange + public operator fun rangeTo(other: Byte): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): FloatRange + public operator fun rangeTo(other: Short): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): FloatRange + public operator fun rangeTo(other: Int): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): FloatRange + public operator fun rangeTo(other: Long): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): FloatRange + public operator fun rangeTo(other: Float): FloatRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -760,124 +760,124 @@ public class Double private () : Number, Comparable { * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Byte): Int + public operator fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Short): Int + public operator fun compareTo(other: Short): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Int): Int + public operator fun compareTo(other: Int): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Long): Int + public operator fun compareTo(other: Long): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public fun compareTo(other: Float): Int + public operator fun compareTo(other: Float): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ - public override fun compareTo(other: Double): Int + public override operator fun compareTo(other: Double): Int /** Adds the other value to this value. */ - public fun plus(other: Byte): Double + public operator fun plus(other: Byte): Double /** Adds the other value to this value. */ - public fun plus(other: Short): Double + public operator fun plus(other: Short): Double /** Adds the other value to this value. */ - public fun plus(other: Int): Double + public operator fun plus(other: Int): Double /** Adds the other value to this value. */ - public fun plus(other: Long): Double + public operator fun plus(other: Long): Double /** Adds the other value to this value. */ - public fun plus(other: Float): Double + public operator fun plus(other: Float): Double /** Adds the other value to this value. */ - public fun plus(other: Double): Double + public operator fun plus(other: Double): Double /** Subtracts the other value from this value. */ - public fun minus(other: Byte): Double + public operator fun minus(other: Byte): Double /** Subtracts the other value from this value. */ - public fun minus(other: Short): Double + public operator fun minus(other: Short): Double /** Subtracts the other value from this value. */ - public fun minus(other: Int): Double + public operator fun minus(other: Int): Double /** Subtracts the other value from this value. */ - public fun minus(other: Long): Double + public operator fun minus(other: Long): Double /** Subtracts the other value from this value. */ - public fun minus(other: Float): Double + public operator fun minus(other: Float): Double /** Subtracts the other value from this value. */ - public fun minus(other: Double): Double + public operator fun minus(other: Double): Double /** Multiplies this value by the other value. */ - public fun times(other: Byte): Double + public operator fun times(other: Byte): Double /** Multiplies this value by the other value. */ - public fun times(other: Short): Double + public operator fun times(other: Short): Double /** Multiplies this value by the other value. */ - public fun times(other: Int): Double + public operator fun times(other: Int): Double /** Multiplies this value by the other value. */ - public fun times(other: Long): Double + public operator fun times(other: Long): Double /** Multiplies this value by the other value. */ - public fun times(other: Float): Double + public operator fun times(other: Float): Double /** Multiplies this value by the other value. */ - public fun times(other: Double): Double + public operator fun times(other: Double): Double /** Divides this value by the other value. */ - public fun div(other: Byte): Double + public operator fun div(other: Byte): Double /** Divides this value by the other value. */ - public fun div(other: Short): Double + public operator fun div(other: Short): Double /** Divides this value by the other value. */ - public fun div(other: Int): Double + public operator fun div(other: Int): Double /** Divides this value by the other value. */ - public fun div(other: Long): Double + public operator fun div(other: Long): Double /** Divides this value by the other value. */ - public fun div(other: Float): Double + public operator fun div(other: Float): Double /** Divides this value by the other value. */ - public fun div(other: Double): Double + public operator fun div(other: Double): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Byte): Double + public operator fun mod(other: Byte): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Short): Double + public operator fun mod(other: Short): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Int): Double + public operator fun mod(other: Int): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Long): Double + public operator fun mod(other: Long): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Float): Double + public operator fun mod(other: Float): Double /** Calculates the remainder of dividing this value by the other value. */ - public fun mod(other: Double): Double + public operator fun mod(other: Double): Double /** Increments this value. */ - public fun inc(): Double + public operator fun inc(): Double /** Decrements this value. */ - public fun dec(): Double + public operator fun dec(): Double /** Returns this value. */ - public fun plus(): Double + public operator fun plus(): Double /** Returns the negative of this value. */ - public fun minus(): Double + public operator fun minus(): Double /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Byte): DoubleRange + public operator fun rangeTo(other: Byte): DoubleRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Short): DoubleRange + public operator fun rangeTo(other: Short): DoubleRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Int): DoubleRange + public operator fun rangeTo(other: Int): DoubleRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Long): DoubleRange + public operator fun rangeTo(other: Long): DoubleRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Float): DoubleRange + public operator fun rangeTo(other: Float): DoubleRange /** Creates a range from this value to the specified [other] value. */ - public fun rangeTo(other: Double): DoubleRange + public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char diff --git a/core/builtins/native/kotlin/String.kt b/core/builtins/native/kotlin/String.kt index a889d01a000..5a8f939ab5d 100644 --- a/core/builtins/native/kotlin/String.kt +++ b/core/builtins/native/kotlin/String.kt @@ -26,12 +26,12 @@ public class String : Comparable, CharSequence { /** * Returns a string obtained by concatenating this string with the string representation of the given [other] object. */ - public fun plus(other: Any?): String + public operator fun plus(other: Any?): String /** * Returns the character at the specified [index]. */ - public fun get(index: Int): Char + public operator fun get(index: Int): Char public override fun length(): Int diff --git a/core/builtins/src/kotlin/Range.kt b/core/builtins/src/kotlin/Range.kt index aeff20cfaa3..a1dd9f360b6 100644 --- a/core/builtins/src/kotlin/Range.kt +++ b/core/builtins/src/kotlin/Range.kt @@ -34,7 +34,7 @@ public interface Range> { /** * Checks if the specified value belongs to the range. */ - public fun contains(item: T): Boolean + public operator fun contains(item: T): Boolean /** * Checks if the range is empty. diff --git a/core/runtime.jvm/src/kotlin/jvm/functions/Functions.kt b/core/runtime.jvm/src/kotlin/jvm/functions/Functions.kt index 8d7174c2c35..9ae1ec041ba 100644 --- a/core/runtime.jvm/src/kotlin/jvm/functions/Functions.kt +++ b/core/runtime.jvm/src/kotlin/jvm/functions/Functions.kt @@ -21,115 +21,115 @@ package kotlin.jvm.functions /** A function that takes 0 arguments. */ public interface Function0 : Function { /** Invokes the function. */ - public fun invoke(): R + public operator fun invoke(): R } /** A function that takes 1 argument. */ public interface Function1 : Function { /** Invokes the function with the specified argument. */ - public fun invoke(p1: P1): R + public operator fun invoke(p1: P1): R } /** A function that takes 2 arguments. */ public interface Function2 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2): R + public operator fun invoke(p1: P1, p2: P2): R } /** A function that takes 3 arguments. */ public interface Function3 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3): R + public operator fun invoke(p1: P1, p2: P2, p3: P3): R } /** A function that takes 4 arguments. */ public interface Function4 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R } /** A function that takes 5 arguments. */ public interface Function5 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R } /** A function that takes 6 arguments. */ public interface Function6 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R } /** A function that takes 7 arguments. */ public interface Function7 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R } /** A function that takes 8 arguments. */ public interface Function8 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R } /** A function that takes 9 arguments. */ public interface Function9 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R } /** A function that takes 10 arguments. */ public interface Function10 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R } /** A function that takes 11 arguments. */ public interface Function11 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R } /** A function that takes 12 arguments. */ public interface Function12 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R } /** A function that takes 13 arguments. */ public interface Function13 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R } /** A function that takes 14 arguments. */ public interface Function14 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R } /** A function that takes 15 arguments. */ public interface Function15 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R } /** A function that takes 16 arguments. */ public interface Function16 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R } /** A function that takes 17 arguments. */ public interface Function17 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R } /** A function that takes 18 arguments. */ public interface Function18 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R } /** A function that takes 19 arguments. */ public interface Function19 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R } /** A function that takes 20 arguments. */ public interface Function20 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R } /** A function that takes 21 arguments. */ public interface Function21 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R } /** A function that takes 22 arguments. */ public interface Function22 : Function { /** Invokes the function with the specified arguments. */ - public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R + public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt index 3499e9c739b..1e44baec9e8 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ArrayIterators.kt @@ -66,11 +66,11 @@ private class ArrayBooleanIterator(private val array: BooleanArray) : BooleanIte override fun nextBoolean() = array[index++] } -public fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array) -public fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array) -public fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array) -public fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array) -public fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array) -public fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array) -public fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array) -public fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array) +public operator fun iterator(array: ByteArray): ByteIterator = ArrayByteIterator(array) +public operator fun iterator(array: CharArray): CharIterator = ArrayCharIterator(array) +public operator fun iterator(array: ShortArray): ShortIterator = ArrayShortIterator(array) +public operator fun iterator(array: IntArray): IntIterator = ArrayIntIterator(array) +public operator fun iterator(array: LongArray): LongIterator = ArrayLongIterator(array) +public operator fun iterator(array: FloatArray): FloatIterator = ArrayFloatIterator(array) +public operator fun iterator(array: DoubleArray): DoubleIterator = ArrayDoubleIterator(array) +public operator fun iterator(array: BooleanArray): BooleanIterator = ArrayBooleanIterator(array) diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/arrayIterators.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/arrayIterators.kt index aed146d81d8..e44cc1985a5 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/arrayIterators.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/arrayIterators.kt @@ -35,7 +35,7 @@ class GenerateArrayIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) { } for (kind in PrimitiveType.values()) { val s = kind.capitalized - out.println("public fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)") + out.println("public operator fun iterator(array: ${s}Array): ${s}Iterator = Array${s}Iterator(array)") } } } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt index e34f7c12bbb..17b74c82ede 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt @@ -34,15 +34,15 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) { out.println(" */") out.println("public class ${s}Array(size: Int) : Cloneable {") out.println(" /** Returns the array element at the given [index]. This method can be called using the index operator. */") - out.println(" public fun get(index: Int): $s") + out.println(" public operator fun get(index: Int): $s") out.println(" /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */") - out.println(" public fun set(index: Int, value: $s): Unit") + out.println(" public operator fun set(index: Int, value: $s): Unit") out.println() out.println(" /** Returns the number of elements in the array. */") out.println(" public fun size(): Int") out.println() out.println(" /** Creates an iterator over the elements of the array. */") - out.println(" public fun iterator(): ${s}Iterator") + out.println(" public operator fun iterator(): ${s}Iterator") out.println() out.println(" public override fun clone(): ${s}Array") out.println("}") diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt index 25c1625bfb6..7670a0d8564 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt @@ -77,7 +77,7 @@ class GenerateFunctions(out: PrintWriter) : BuiltInsSourceGenerator(out) { val suffix = if (i == 1) "" else "s" out.println(" /** Invokes the function with the specified argument${suffix}. */") } - out.print(" public fun invoke(") + out.print(" public operator fun invoke(") for (j in 1..i) { out.print("p$j: P$j") if (j < i) { diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index 0b2b85af5ef..879584eabb6 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -98,7 +98,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { out.println(" */") out.print(" public ") if (otherKind == thisKind) out.print("override ") - out.println("fun compareTo(other: ${otherKind.capitalized}): Int") + out.println("operator fun compareTo(other: ${otherKind.capitalized}): Int") } out.println() } @@ -113,7 +113,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { for (otherKind in PrimitiveType.onlyNumeric) { val returnType = getOperatorReturnType(thisKind, otherKind) out.println(" /** $doc */") - out.println(" public fun $name(other: ${otherKind.capitalized}): $returnType") + out.println(" public operator fun $name(other: ${otherKind.capitalized}): $returnType") } out.println() } @@ -122,7 +122,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { for (otherKind in PrimitiveType.onlyNumeric) { val returnType = if (otherKind.ordinal() > thisKind.ordinal()) otherKind else thisKind out.println(" /** Creates a range from this value to the specified [other] value. */") - out.println(" public fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range") + out.println(" public operator fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range") } out.println() @@ -133,7 +133,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { val returnType = if (kind in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) && name in listOf("plus", "minus")) "Int" else kind.capitalized out.println(" /** $doc */") - out.println(" public fun $name(): $returnType") + out.println(" public operator fun $name(): $returnType") } out.println() } diff --git a/libraries/stdlib/src/generated/_Elements.kt b/libraries/stdlib/src/generated/_Elements.kt index 207e07766f3..016a66fd177 100644 --- a/libraries/stdlib/src/generated/_Elements.kt +++ b/libraries/stdlib/src/generated/_Elements.kt @@ -14,7 +14,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun Array.component1(): T { +public inline operator fun Array.component1(): T { return get(0) } @@ -22,7 +22,7 @@ public inline fun Array.component1(): T { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun BooleanArray.component1(): Boolean { +public inline operator fun BooleanArray.component1(): Boolean { return get(0) } @@ -30,7 +30,7 @@ public inline fun BooleanArray.component1(): Boolean { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ByteArray.component1(): Byte { +public inline operator fun ByteArray.component1(): Byte { return get(0) } @@ -38,7 +38,7 @@ public inline fun ByteArray.component1(): Byte { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun CharArray.component1(): Char { +public inline operator fun CharArray.component1(): Char { return get(0) } @@ -46,7 +46,7 @@ public inline fun CharArray.component1(): Char { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun DoubleArray.component1(): Double { +public inline operator fun DoubleArray.component1(): Double { return get(0) } @@ -54,7 +54,7 @@ public inline fun DoubleArray.component1(): Double { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun FloatArray.component1(): Float { +public inline operator fun FloatArray.component1(): Float { return get(0) } @@ -62,7 +62,7 @@ public inline fun FloatArray.component1(): Float { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun IntArray.component1(): Int { +public inline operator fun IntArray.component1(): Int { return get(0) } @@ -70,7 +70,7 @@ public inline fun IntArray.component1(): Int { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun LongArray.component1(): Long { +public inline operator fun LongArray.component1(): Long { return get(0) } @@ -78,7 +78,7 @@ public inline fun LongArray.component1(): Long { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ShortArray.component1(): Short { +public inline operator fun ShortArray.component1(): Short { return get(0) } @@ -86,7 +86,7 @@ public inline fun ShortArray.component1(): Short { * Returns 1st *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun List.component1(): T { +public inline operator fun List.component1(): T { return get(0) } @@ -94,7 +94,7 @@ public inline fun List.component1(): T { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun Array.component2(): T { +public inline operator fun Array.component2(): T { return get(1) } @@ -102,7 +102,7 @@ public inline fun Array.component2(): T { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun BooleanArray.component2(): Boolean { +public inline operator fun BooleanArray.component2(): Boolean { return get(1) } @@ -110,7 +110,7 @@ public inline fun BooleanArray.component2(): Boolean { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ByteArray.component2(): Byte { +public inline operator fun ByteArray.component2(): Byte { return get(1) } @@ -118,7 +118,7 @@ public inline fun ByteArray.component2(): Byte { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun CharArray.component2(): Char { +public inline operator fun CharArray.component2(): Char { return get(1) } @@ -126,7 +126,7 @@ public inline fun CharArray.component2(): Char { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun DoubleArray.component2(): Double { +public inline operator fun DoubleArray.component2(): Double { return get(1) } @@ -134,7 +134,7 @@ public inline fun DoubleArray.component2(): Double { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun FloatArray.component2(): Float { +public inline operator fun FloatArray.component2(): Float { return get(1) } @@ -142,7 +142,7 @@ public inline fun FloatArray.component2(): Float { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun IntArray.component2(): Int { +public inline operator fun IntArray.component2(): Int { return get(1) } @@ -150,7 +150,7 @@ public inline fun IntArray.component2(): Int { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun LongArray.component2(): Long { +public inline operator fun LongArray.component2(): Long { return get(1) } @@ -158,7 +158,7 @@ public inline fun LongArray.component2(): Long { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ShortArray.component2(): Short { +public inline operator fun ShortArray.component2(): Short { return get(1) } @@ -166,7 +166,7 @@ public inline fun ShortArray.component2(): Short { * Returns 2nd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun List.component2(): T { +public inline operator fun List.component2(): T { return get(1) } @@ -174,7 +174,7 @@ public inline fun List.component2(): T { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun Array.component3(): T { +public inline operator fun Array.component3(): T { return get(2) } @@ -182,7 +182,7 @@ public inline fun Array.component3(): T { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun BooleanArray.component3(): Boolean { +public inline operator fun BooleanArray.component3(): Boolean { return get(2) } @@ -190,7 +190,7 @@ public inline fun BooleanArray.component3(): Boolean { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ByteArray.component3(): Byte { +public inline operator fun ByteArray.component3(): Byte { return get(2) } @@ -198,7 +198,7 @@ public inline fun ByteArray.component3(): Byte { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun CharArray.component3(): Char { +public inline operator fun CharArray.component3(): Char { return get(2) } @@ -206,7 +206,7 @@ public inline fun CharArray.component3(): Char { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun DoubleArray.component3(): Double { +public inline operator fun DoubleArray.component3(): Double { return get(2) } @@ -214,7 +214,7 @@ public inline fun DoubleArray.component3(): Double { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun FloatArray.component3(): Float { +public inline operator fun FloatArray.component3(): Float { return get(2) } @@ -222,7 +222,7 @@ public inline fun FloatArray.component3(): Float { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun IntArray.component3(): Int { +public inline operator fun IntArray.component3(): Int { return get(2) } @@ -230,7 +230,7 @@ public inline fun IntArray.component3(): Int { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun LongArray.component3(): Long { +public inline operator fun LongArray.component3(): Long { return get(2) } @@ -238,7 +238,7 @@ public inline fun LongArray.component3(): Long { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ShortArray.component3(): Short { +public inline operator fun ShortArray.component3(): Short { return get(2) } @@ -246,7 +246,7 @@ public inline fun ShortArray.component3(): Short { * Returns 3rd *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun List.component3(): T { +public inline operator fun List.component3(): T { return get(2) } @@ -254,7 +254,7 @@ public inline fun List.component3(): T { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun Array.component4(): T { +public inline operator fun Array.component4(): T { return get(3) } @@ -262,7 +262,7 @@ public inline fun Array.component4(): T { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun BooleanArray.component4(): Boolean { +public inline operator fun BooleanArray.component4(): Boolean { return get(3) } @@ -270,7 +270,7 @@ public inline fun BooleanArray.component4(): Boolean { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ByteArray.component4(): Byte { +public inline operator fun ByteArray.component4(): Byte { return get(3) } @@ -278,7 +278,7 @@ public inline fun ByteArray.component4(): Byte { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun CharArray.component4(): Char { +public inline operator fun CharArray.component4(): Char { return get(3) } @@ -286,7 +286,7 @@ public inline fun CharArray.component4(): Char { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun DoubleArray.component4(): Double { +public inline operator fun DoubleArray.component4(): Double { return get(3) } @@ -294,7 +294,7 @@ public inline fun DoubleArray.component4(): Double { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun FloatArray.component4(): Float { +public inline operator fun FloatArray.component4(): Float { return get(3) } @@ -302,7 +302,7 @@ public inline fun FloatArray.component4(): Float { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun IntArray.component4(): Int { +public inline operator fun IntArray.component4(): Int { return get(3) } @@ -310,7 +310,7 @@ public inline fun IntArray.component4(): Int { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun LongArray.component4(): Long { +public inline operator fun LongArray.component4(): Long { return get(3) } @@ -318,7 +318,7 @@ public inline fun LongArray.component4(): Long { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ShortArray.component4(): Short { +public inline operator fun ShortArray.component4(): Short { return get(3) } @@ -326,7 +326,7 @@ public inline fun ShortArray.component4(): Short { * Returns 4th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun List.component4(): T { +public inline operator fun List.component4(): T { return get(3) } @@ -334,7 +334,7 @@ public inline fun List.component4(): T { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun Array.component5(): T { +public inline operator fun Array.component5(): T { return get(4) } @@ -342,7 +342,7 @@ public inline fun Array.component5(): T { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun BooleanArray.component5(): Boolean { +public inline operator fun BooleanArray.component5(): Boolean { return get(4) } @@ -350,7 +350,7 @@ public inline fun BooleanArray.component5(): Boolean { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ByteArray.component5(): Byte { +public inline operator fun ByteArray.component5(): Byte { return get(4) } @@ -358,7 +358,7 @@ public inline fun ByteArray.component5(): Byte { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun CharArray.component5(): Char { +public inline operator fun CharArray.component5(): Char { return get(4) } @@ -366,7 +366,7 @@ public inline fun CharArray.component5(): Char { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun DoubleArray.component5(): Double { +public inline operator fun DoubleArray.component5(): Double { return get(4) } @@ -374,7 +374,7 @@ public inline fun DoubleArray.component5(): Double { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun FloatArray.component5(): Float { +public inline operator fun FloatArray.component5(): Float { return get(4) } @@ -382,7 +382,7 @@ public inline fun FloatArray.component5(): Float { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun IntArray.component5(): Int { +public inline operator fun IntArray.component5(): Int { return get(4) } @@ -390,7 +390,7 @@ public inline fun IntArray.component5(): Int { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun LongArray.component5(): Long { +public inline operator fun LongArray.component5(): Long { return get(4) } @@ -398,7 +398,7 @@ public inline fun LongArray.component5(): Long { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun ShortArray.component5(): Short { +public inline operator fun ShortArray.component5(): Short { return get(4) } @@ -406,77 +406,77 @@ public inline fun ShortArray.component5(): Short { * Returns 5th *element* from the collection. */ @Suppress("NOTHING_TO_INLINE") -public inline fun List.component5(): T { +public inline operator fun List.component5(): T { return get(4) } /** * Returns `true` if [element] is found in the collection. */ -public fun Array.contains(element: T): Boolean { +public operator fun Array.contains(element: T): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun BooleanArray.contains(element: Boolean): Boolean { +public operator fun BooleanArray.contains(element: Boolean): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun ByteArray.contains(element: Byte): Boolean { +public operator fun ByteArray.contains(element: Byte): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun CharArray.contains(element: Char): Boolean { +public operator fun CharArray.contains(element: Char): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun DoubleArray.contains(element: Double): Boolean { +public operator fun DoubleArray.contains(element: Double): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun FloatArray.contains(element: Float): Boolean { +public operator fun FloatArray.contains(element: Float): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun IntArray.contains(element: Int): Boolean { +public operator fun IntArray.contains(element: Int): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun LongArray.contains(element: Long): Boolean { +public operator fun LongArray.contains(element: Long): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun ShortArray.contains(element: Short): Boolean { +public operator fun ShortArray.contains(element: Short): Boolean { return indexOf(element) >= 0 } /** * Returns `true` if [element] is found in the collection. */ -public fun Iterable.contains(element: T): Boolean { +public operator fun Iterable.contains(element: T): Boolean { if (this is Collection) return contains(element) return indexOf(element) >= 0 @@ -485,7 +485,7 @@ public fun Iterable.contains(element: T): Boolean { /** * Returns `true` if [element] is found in the collection. */ -public fun Sequence.contains(element: T): Boolean { +public operator fun Sequence.contains(element: T): Boolean { return indexOf(element) >= 0 } diff --git a/libraries/stdlib/src/generated/_Generators.kt b/libraries/stdlib/src/generated/_Generators.kt index 51ba432eb21..2e2d293ebb5 100644 --- a/libraries/stdlib/src/generated/_Generators.kt +++ b/libraries/stdlib/src/generated/_Generators.kt @@ -377,7 +377,7 @@ public fun Sequence.merge(sequence: Sequence, transform: (T, R) /** * Returns a list containing all elements of the original collection except the elements contained in the given [array]. */ -public fun Iterable.minus(array: Array): List { +public operator fun Iterable.minus(array: Array): List { if (array.isEmpty()) return this.toList() val other = array.toHashSet() return this.filterNot { it in other } @@ -388,7 +388,7 @@ public fun Iterable.minus(array: Array): List { * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.minus(array: Array): Sequence { +public operator fun Sequence.minus(array: Array): Sequence { if (array.isEmpty()) return this return object: Sequence { override fun iterator(): Iterator { @@ -401,7 +401,7 @@ public fun Sequence.minus(array: Array): Sequence { /** * Returns a set containing all elements of the original set except the elements contained in the given [array]. */ -public fun Set.minus(array: Array): Set { +public operator fun Set.minus(array: Array): Set { val result = LinkedHashSet(this) result.removeAll(array) return result @@ -410,7 +410,7 @@ public fun Set.minus(array: Array): Set { /** * Returns a list containing all elements of the original collection except the elements contained in the given [collection]. */ -public fun Iterable.minus(collection: Iterable): List { +public operator fun Iterable.minus(collection: Iterable): List { val other = collection.convertToSetForSetOperationWith(this) if (other.isEmpty()) return this.toList() @@ -422,7 +422,7 @@ public fun Iterable.minus(collection: Iterable): List { * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.minus(collection: Iterable): Sequence { +public operator fun Sequence.minus(collection: Iterable): Sequence { return object: Sequence { override fun iterator(): Iterator { val other = collection.convertToSetForSetOperation() @@ -437,7 +437,7 @@ public fun Sequence.minus(collection: Iterable): Sequence { /** * Returns a set containing all elements of the original set except the elements contained in the given [collection]. */ -public fun Set.minus(collection: Iterable): Set { +public operator fun Set.minus(collection: Iterable): Set { val other = collection.convertToSetForSetOperationWith(this) if (other.isEmpty()) return this.toSet() @@ -451,7 +451,7 @@ public fun Set.minus(collection: Iterable): Set { /** * Returns a list containing all elements of the original collection without the first occurrence of the given [element]. */ -public fun Iterable.minus(element: T): List { +public operator fun Iterable.minus(element: T): List { val result = ArrayList(collectionSizeOrDefault(10)) var removed = false return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true } @@ -460,7 +460,7 @@ public fun Iterable.minus(element: T): List { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. */ -public fun Sequence.minus(element: T): Sequence { +public operator fun Sequence.minus(element: T): Sequence { return object: Sequence { override fun iterator(): Iterator { var removed = false @@ -472,7 +472,7 @@ public fun Sequence.minus(element: T): Sequence { /** * Returns a set containing all elements of the original set except the given [element]. */ -public fun Set.minus(element: T): Set { +public operator fun Set.minus(element: T): Set { val result = LinkedHashSet(mapCapacity(size())) var removed = false return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true } @@ -481,7 +481,7 @@ public fun Set.minus(element: T): Set { /** * Returns a list containing all elements of the original collection except the elements contained in the given [sequence]. */ -public fun Iterable.minus(sequence: Sequence): List { +public operator fun Iterable.minus(sequence: Sequence): List { val other = sequence.toHashSet() if (other.isEmpty()) return this.toList() @@ -493,7 +493,7 @@ public fun Iterable.minus(sequence: Sequence): List { * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.minus(sequence: Sequence): Sequence { +public operator fun Sequence.minus(sequence: Sequence): Sequence { return object: Sequence { override fun iterator(): Iterator { val other = sequence.toHashSet() @@ -508,7 +508,7 @@ public fun Sequence.minus(sequence: Sequence): Sequence { /** * Returns a set containing all elements of the original set except the elements contained in the given [sequence]. */ -public fun Set.minus(sequence: Sequence): Set { +public operator fun Set.minus(sequence: Sequence): Set { val result = LinkedHashSet(this) result.removeAll(sequence) return result @@ -733,7 +733,7 @@ public inline fun String.partition(predicate: (Char) -> Boolean): Pair Collection.plus(array: Array): List { +public operator fun Collection.plus(array: Array): List { val result = ArrayList(this.size() + array.size()) result.addAll(this) result.addAll(array) @@ -743,7 +743,7 @@ public fun Collection.plus(array: Array): List { /** * Returns a list containing all elements of the original collection and then all elements of the given [array]. */ -public fun Iterable.plus(array: Array): List { +public operator fun Iterable.plus(array: Array): List { if (this is Collection) return this.plus(array) val result = ArrayList() result.addAll(this) @@ -756,14 +756,14 @@ public fun Iterable.plus(array: Array): List { * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.plus(array: Array): Sequence { +public operator fun Sequence.plus(array: Array): Sequence { return this.plus(array.asList()) } /** * Returns a set containing all elements both of the original set and the given [array]. */ -public fun Set.plus(array: Array): Set { +public operator fun Set.plus(array: Array): Set { val result = LinkedHashSet(mapCapacity(this.size() + array.size())) result.addAll(this) result.addAll(array) @@ -773,7 +773,7 @@ public fun Set.plus(array: Array): Set { /** * Returns a list containing all elements of the original collection and then all elements of the given [collection]. */ -public fun Collection.plus(collection: Iterable): List { +public operator fun Collection.plus(collection: Iterable): List { if (collection is Collection) { val result = ArrayList(this.size() + collection.size()) result.addAll(this) @@ -789,7 +789,7 @@ public fun Collection.plus(collection: Iterable): List { /** * Returns a list containing all elements of the original collection and then all elements of the given [collection]. */ -public fun Iterable.plus(collection: Iterable): List { +public operator fun Iterable.plus(collection: Iterable): List { if (this is Collection) return this.plus(collection) val result = ArrayList() result.addAll(this) @@ -802,14 +802,14 @@ public fun Iterable.plus(collection: Iterable): List { * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.plus(collection: Iterable): Sequence { +public operator fun Sequence.plus(collection: Iterable): Sequence { return sequenceOf(this, collection.asSequence()).flatten() } /** * Returns a set containing all elements both of the original set and the given [collection]. */ -public fun Set.plus(collection: Iterable): Set { +public operator fun Set.plus(collection: Iterable): Set { val result = LinkedHashSet(mapCapacity(collection.collectionSizeOrNull()?.let { this.size() + it } ?: this.size() * 2)) result.addAll(this) result.addAll(collection) @@ -819,7 +819,7 @@ public fun Set.plus(collection: Iterable): Set { /** * Returns a list containing all elements of the original collection and then the given [element]. */ -public fun Collection.plus(element: T): List { +public operator fun Collection.plus(element: T): List { val result = ArrayList(size() + 1) result.addAll(this) result.add(element) @@ -829,7 +829,7 @@ public fun Collection.plus(element: T): List { /** * Returns a list containing all elements of the original collection and then the given [element]. */ -public fun Iterable.plus(element: T): List { +public operator fun Iterable.plus(element: T): List { if (this is Collection) return this.plus(element) val result = ArrayList() result.addAll(this) @@ -840,14 +840,14 @@ public fun Iterable.plus(element: T): List { /** * Returns a sequence containing all elements of the original sequence and then the given [element]. */ -public fun Sequence.plus(element: T): Sequence { +public operator fun Sequence.plus(element: T): Sequence { return sequenceOf(this, sequenceOf(element)).flatten() } /** * Returns a set containing all elements of the original set and then the given [element]. */ -public fun Set.plus(element: T): Set { +public operator fun Set.plus(element: T): Set { val result = LinkedHashSet(mapCapacity(size() + 1)) result.addAll(this) result.add(element) @@ -857,7 +857,7 @@ public fun Set.plus(element: T): Set { /** * Returns a list containing all elements of the original collection and then all elements of the given [sequence]. */ -public fun Collection.plus(sequence: Sequence): List { +public operator fun Collection.plus(sequence: Sequence): List { val result = ArrayList(this.size() + 10) result.addAll(this) result.addAll(sequence) @@ -867,7 +867,7 @@ public fun Collection.plus(sequence: Sequence): List { /** * Returns a list containing all elements of the original collection and then all elements of the given [sequence]. */ -public fun Iterable.plus(sequence: Sequence): List { +public operator fun Iterable.plus(sequence: Sequence): List { val result = ArrayList() result.addAll(this) result.addAll(sequence) @@ -879,14 +879,14 @@ public fun Iterable.plus(sequence: Sequence): List { * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ -public fun Sequence.plus(sequence: Sequence): Sequence { +public operator fun Sequence.plus(sequence: Sequence): Sequence { return sequenceOf(this, sequence).flatten() } /** * Returns a set containing all elements both of the original set and the given [sequence]. */ -public fun Set.plus(sequence: Sequence): Set { +public operator fun Set.plus(sequence: Sequence): Set { val result = LinkedHashSet(mapCapacity(this.size() * 2)) result.addAll(this) result.addAll(sequence) diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index 3bbc32e134b..0a085b1cca1 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -14,7 +14,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("intRangeContains") -public fun Range.contains(item: Byte): Boolean { +public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -22,7 +22,7 @@ public fun Range.contains(item: Byte): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("longRangeContains") -public fun Range.contains(item: Byte): Boolean { +public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -30,7 +30,7 @@ public fun Range.contains(item: Byte): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("shortRangeContains") -public fun Range.contains(item: Byte): Boolean { +public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -38,7 +38,7 @@ public fun Range.contains(item: Byte): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("doubleRangeContains") -public fun Range.contains(item: Byte): Boolean { +public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -46,42 +46,42 @@ public fun Range.contains(item: Byte): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("floatRangeContains") -public fun Range.contains(item: Byte): Boolean { +public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Byte item is not supported and should not be used.") -public fun CharRange.contains(item: Byte): Nothing { +public operator fun CharRange.contains(item: Byte): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Int and Char item is not supported and should not be used.") -public fun IntRange.contains(item: Char): Nothing { +public operator fun IntRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Long and Char item is not supported and should not be used.") -public fun LongRange.contains(item: Char): Nothing { +public operator fun LongRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Byte and Char item is not supported and should not be used.") -public fun ByteRange.contains(item: Char): Nothing { +public operator fun ByteRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Short and Char item is not supported and should not be used.") -public fun ShortRange.contains(item: Char): Nothing { +public operator fun ShortRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Double and Char item is not supported and should not be used.") -public fun DoubleRange.contains(item: Char): Nothing { +public operator fun DoubleRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @Deprecated("The 'contains' operation for a range of Float and Char item is not supported and should not be used.") -public fun FloatRange.contains(item: Char): Nothing { +public operator fun FloatRange.contains(item: Char): Nothing { throw UnsupportedOperationException() } @@ -89,7 +89,7 @@ public fun FloatRange.contains(item: Char): Nothing { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("intRangeContains") -public fun Range.contains(item: Double): Boolean { +public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -97,7 +97,7 @@ public fun Range.contains(item: Double): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("longRangeContains") -public fun Range.contains(item: Double): Boolean { +public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -105,7 +105,7 @@ public fun Range.contains(item: Double): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("byteRangeContains") -public fun Range.contains(item: Double): Boolean { +public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -113,7 +113,7 @@ public fun Range.contains(item: Double): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("shortRangeContains") -public fun Range.contains(item: Double): Boolean { +public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -121,12 +121,12 @@ public fun Range.contains(item: Double): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("floatRangeContains") -public fun Range.contains(item: Double): Boolean { +public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Double item is not supported and should not be used.") -public fun CharRange.contains(item: Double): Nothing { +public operator fun CharRange.contains(item: Double): Nothing { throw UnsupportedOperationException() } @@ -134,7 +134,7 @@ public fun CharRange.contains(item: Double): Nothing { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("intRangeContains") -public fun Range.contains(item: Float): Boolean { +public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -142,7 +142,7 @@ public fun Range.contains(item: Float): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("longRangeContains") -public fun Range.contains(item: Float): Boolean { +public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -150,7 +150,7 @@ public fun Range.contains(item: Float): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("byteRangeContains") -public fun Range.contains(item: Float): Boolean { +public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -158,7 +158,7 @@ public fun Range.contains(item: Float): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("shortRangeContains") -public fun Range.contains(item: Float): Boolean { +public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -166,12 +166,12 @@ public fun Range.contains(item: Float): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("doubleRangeContains") -public fun Range.contains(item: Float): Boolean { +public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Float item is not supported and should not be used.") -public fun CharRange.contains(item: Float): Nothing { +public operator fun CharRange.contains(item: Float): Nothing { throw UnsupportedOperationException() } @@ -179,7 +179,7 @@ public fun CharRange.contains(item: Float): Nothing { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("longRangeContains") -public fun Range.contains(item: Int): Boolean { +public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -187,7 +187,7 @@ public fun Range.contains(item: Int): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("byteRangeContains") -public fun Range.contains(item: Int): Boolean { +public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -195,7 +195,7 @@ public fun Range.contains(item: Int): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("shortRangeContains") -public fun Range.contains(item: Int): Boolean { +public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -203,7 +203,7 @@ public fun Range.contains(item: Int): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("doubleRangeContains") -public fun Range.contains(item: Int): Boolean { +public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -211,12 +211,12 @@ public fun Range.contains(item: Int): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("floatRangeContains") -public fun Range.contains(item: Int): Boolean { +public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Int item is not supported and should not be used.") -public fun CharRange.contains(item: Int): Nothing { +public operator fun CharRange.contains(item: Int): Nothing { throw UnsupportedOperationException() } @@ -224,7 +224,7 @@ public fun CharRange.contains(item: Int): Nothing { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("intRangeContains") -public fun Range.contains(item: Long): Boolean { +public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -232,7 +232,7 @@ public fun Range.contains(item: Long): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("byteRangeContains") -public fun Range.contains(item: Long): Boolean { +public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -240,7 +240,7 @@ public fun Range.contains(item: Long): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("shortRangeContains") -public fun Range.contains(item: Long): Boolean { +public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -248,7 +248,7 @@ public fun Range.contains(item: Long): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("doubleRangeContains") -public fun Range.contains(item: Long): Boolean { +public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -256,12 +256,12 @@ public fun Range.contains(item: Long): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("floatRangeContains") -public fun Range.contains(item: Long): Boolean { +public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Long item is not supported and should not be used.") -public fun CharRange.contains(item: Long): Nothing { +public operator fun CharRange.contains(item: Long): Nothing { throw UnsupportedOperationException() } @@ -269,7 +269,7 @@ public fun CharRange.contains(item: Long): Nothing { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("intRangeContains") -public fun Range.contains(item: Short): Boolean { +public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -277,7 +277,7 @@ public fun Range.contains(item: Short): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("longRangeContains") -public fun Range.contains(item: Short): Boolean { +public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -285,7 +285,7 @@ public fun Range.contains(item: Short): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("byteRangeContains") -public fun Range.contains(item: Short): Boolean { +public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -293,7 +293,7 @@ public fun Range.contains(item: Short): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("doubleRangeContains") -public fun Range.contains(item: Short): Boolean { +public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -301,12 +301,12 @@ public fun Range.contains(item: Short): Boolean { * Checks if the specified [item] belongs to this range. */ @kotlin.jvm.JvmName("floatRangeContains") -public fun Range.contains(item: Short): Boolean { +public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @Deprecated("The 'contains' operation for a range of Char and Short item is not supported and should not be used.") -public fun CharRange.contains(item: Short): Nothing { +public operator fun CharRange.contains(item: Short): Nothing { throw UnsupportedOperationException() } diff --git a/libraries/stdlib/src/generated/_SpecialJVM.kt b/libraries/stdlib/src/generated/_SpecialJVM.kt index b546d0dc1ea..70c49469264 100644 --- a/libraries/stdlib/src/generated/_SpecialJVM.kt +++ b/libraries/stdlib/src/generated/_SpecialJVM.kt @@ -569,7 +569,7 @@ public fun , R> Sequence<*>.filterIsInstanceTo(desti /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun BooleanArray.plus(array: BooleanArray): BooleanArray { +public operator fun BooleanArray.plus(array: BooleanArray): BooleanArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -580,7 +580,7 @@ public fun BooleanArray.plus(array: BooleanArray): BooleanArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun ByteArray.plus(array: ByteArray): ByteArray { +public operator fun ByteArray.plus(array: ByteArray): ByteArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -591,7 +591,7 @@ public fun ByteArray.plus(array: ByteArray): ByteArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun CharArray.plus(array: CharArray): CharArray { +public operator fun CharArray.plus(array: CharArray): CharArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -602,7 +602,7 @@ public fun CharArray.plus(array: CharArray): CharArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun DoubleArray.plus(array: DoubleArray): DoubleArray { +public operator fun DoubleArray.plus(array: DoubleArray): DoubleArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -613,7 +613,7 @@ public fun DoubleArray.plus(array: DoubleArray): DoubleArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun FloatArray.plus(array: FloatArray): FloatArray { +public operator fun FloatArray.plus(array: FloatArray): FloatArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -624,7 +624,7 @@ public fun FloatArray.plus(array: FloatArray): FloatArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun IntArray.plus(array: IntArray): IntArray { +public operator fun IntArray.plus(array: IntArray): IntArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -635,7 +635,7 @@ public fun IntArray.plus(array: IntArray): IntArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun LongArray.plus(array: LongArray): LongArray { +public operator fun LongArray.plus(array: LongArray): LongArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -646,7 +646,7 @@ public fun LongArray.plus(array: LongArray): LongArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun ShortArray.plus(array: ShortArray): ShortArray { +public operator fun ShortArray.plus(array: ShortArray): ShortArray { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -657,7 +657,7 @@ public fun ShortArray.plus(array: ShortArray): ShortArray { /** * Returns an array containing all elements of the original array and then all elements of the given [array]. */ -public fun Array.plus(array: Array): Array { +public operator fun Array.plus(array: Array): Array { val thisSize = size() val arraySize = array.size() val result = Arrays.copyOf(this, thisSize + arraySize) @@ -668,7 +668,7 @@ public fun Array.plus(array: Array): Array { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun BooleanArray.plus(collection: Collection): BooleanArray { +public operator fun BooleanArray.plus(collection: Collection): BooleanArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -678,7 +678,7 @@ public fun BooleanArray.plus(collection: Collection): BooleanArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun ByteArray.plus(collection: Collection): ByteArray { +public operator fun ByteArray.plus(collection: Collection): ByteArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -688,7 +688,7 @@ public fun ByteArray.plus(collection: Collection): ByteArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun CharArray.plus(collection: Collection): CharArray { +public operator fun CharArray.plus(collection: Collection): CharArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -698,7 +698,7 @@ public fun CharArray.plus(collection: Collection): CharArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun DoubleArray.plus(collection: Collection): DoubleArray { +public operator fun DoubleArray.plus(collection: Collection): DoubleArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -708,7 +708,7 @@ public fun DoubleArray.plus(collection: Collection): DoubleArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun FloatArray.plus(collection: Collection): FloatArray { +public operator fun FloatArray.plus(collection: Collection): FloatArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -718,7 +718,7 @@ public fun FloatArray.plus(collection: Collection): FloatArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun IntArray.plus(collection: Collection): IntArray { +public operator fun IntArray.plus(collection: Collection): IntArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -728,7 +728,7 @@ public fun IntArray.plus(collection: Collection): IntArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun LongArray.plus(collection: Collection): LongArray { +public operator fun LongArray.plus(collection: Collection): LongArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -738,7 +738,7 @@ public fun LongArray.plus(collection: Collection): LongArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun ShortArray.plus(collection: Collection): ShortArray { +public operator fun ShortArray.plus(collection: Collection): ShortArray { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -748,7 +748,7 @@ public fun ShortArray.plus(collection: Collection): ShortArray { /** * Returns an array containing all elements of the original array and then all elements of the given [collection]. */ -public fun Array.plus(collection: Collection): Array { +public operator fun Array.plus(collection: Collection): Array { var index = size() val result = Arrays.copyOf(this, index + collection.size()) for (element in collection) result[index++] = element @@ -758,7 +758,7 @@ public fun Array.plus(collection: Collection): Array { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun BooleanArray.plus(element: Boolean): BooleanArray { +public operator fun BooleanArray.plus(element: Boolean): BooleanArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -768,7 +768,7 @@ public fun BooleanArray.plus(element: Boolean): BooleanArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun ByteArray.plus(element: Byte): ByteArray { +public operator fun ByteArray.plus(element: Byte): ByteArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -778,7 +778,7 @@ public fun ByteArray.plus(element: Byte): ByteArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun CharArray.plus(element: Char): CharArray { +public operator fun CharArray.plus(element: Char): CharArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -788,7 +788,7 @@ public fun CharArray.plus(element: Char): CharArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun DoubleArray.plus(element: Double): DoubleArray { +public operator fun DoubleArray.plus(element: Double): DoubleArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -798,7 +798,7 @@ public fun DoubleArray.plus(element: Double): DoubleArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun FloatArray.plus(element: Float): FloatArray { +public operator fun FloatArray.plus(element: Float): FloatArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -808,7 +808,7 @@ public fun FloatArray.plus(element: Float): FloatArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun IntArray.plus(element: Int): IntArray { +public operator fun IntArray.plus(element: Int): IntArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -818,7 +818,7 @@ public fun IntArray.plus(element: Int): IntArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun LongArray.plus(element: Long): LongArray { +public operator fun LongArray.plus(element: Long): LongArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -828,7 +828,7 @@ public fun LongArray.plus(element: Long): LongArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun ShortArray.plus(element: Short): ShortArray { +public operator fun ShortArray.plus(element: Short): ShortArray { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -838,7 +838,7 @@ public fun ShortArray.plus(element: Short): ShortArray { /** * Returns an array containing all elements of the original array and then the given [element]. */ -public fun Array.plus(element: T): Array { +public operator fun Array.plus(element: T): Array { val index = size() val result = Arrays.copyOf(this, index + 1) result[index] = element diff --git a/libraries/stdlib/src/kotlin/collections/Iterators.kt b/libraries/stdlib/src/kotlin/collections/Iterators.kt index f764c644178..8ebd96bfc7a 100644 --- a/libraries/stdlib/src/kotlin/collections/Iterators.kt +++ b/libraries/stdlib/src/kotlin/collections/Iterators.kt @@ -5,7 +5,7 @@ import java.util.Enumeration /** * Creates an [Iterator] for an [Enumeration], allowing to use it in `for` loops. */ -public fun Enumeration.iterator(): Iterator = object : Iterator { +public operator fun Enumeration.iterator(): Iterator = object : Iterator { override fun hasNext(): Boolean = hasMoreElements() public override fun next(): T = nextElement() @@ -14,7 +14,7 @@ public fun Enumeration.iterator(): Iterator = object : Iterator { /** * Returns the given iterator itself. This allows to use an instance of iterator in a `for` loop. */ -public fun Iterator.iterator(): Iterator = this +public operator fun Iterator.iterator(): Iterator = this /** * Performs the given [operation] on each element of this [Iterator]. diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 4e2fbee23a7..8cbc17c4744 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -91,7 +91,7 @@ public fun Map?.orEmpty() : Map = this ?: emptyMap() * Checks if the map contains the given key. This method allows to use the `x in map` syntax for checking * whether an object is contained in the map. */ -public fun Map.contains(key : K) : Boolean = containsKey(key) +public operator fun Map.contains(key : K) : Boolean = containsKey(key) /** * Allows to access the key of a map entry as a property. Equivalent to `getKey()`. @@ -115,7 +115,7 @@ public val Map.Entry.value: V * } * ``` */ -public fun Map.Entry.component1(): K { +public operator fun Map.Entry.component1(): K { return getKey() } @@ -128,7 +128,7 @@ public fun Map.Entry.component1(): K { * } * ``` */ -public fun Map.Entry.component2(): V { +public operator fun Map.Entry.component2(): V { return getValue() } @@ -175,7 +175,7 @@ public inline fun MutableMap.getOrPut(key: K, defaultValue: () -> V * * @sample test.collections.MapTest.iterateWithProperties */ -public fun Map.iterator(): Iterator> { +public operator fun Map.iterator(): Iterator> { val entrySet = entrySet() return entrySet.iterator() } @@ -362,7 +362,7 @@ public fun Map.toLinkedMap(): MutableMap = LinkedHashMap(this /** * Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair]. */ -public fun Map.plus(pair: Pair): Map { +public operator fun Map.plus(pair: Pair): Map { val newMap = this.toLinkedMap() newMap.put(pair.first, pair.second) return newMap @@ -371,7 +371,7 @@ public fun Map.plus(pair: Pair): Map { /** * Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs]. */ -public fun Map.plus(pairs: Iterable>): Map { +public operator fun Map.plus(pairs: Iterable>): Map { val newMap = this.toLinkedMap() newMap.putAll(pairs) return newMap @@ -380,7 +380,7 @@ public fun Map.plus(pairs: Iterable>): Map { /** * Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs]. */ -public fun Map.plus(pairs: Array>): Map { +public operator fun Map.plus(pairs: Array>): Map { val newMap = this.toLinkedMap() newMap.putAll(*pairs) return newMap @@ -389,7 +389,7 @@ public fun Map.plus(pairs: Array>): Map { /** * Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs]. */ -public fun Map.plus(pairs: Sequence>): Map { +public operator fun Map.plus(pairs: Sequence>): Map { val newMap = this.toLinkedMap() newMap.putAll(pairs) return newMap @@ -398,7 +398,7 @@ public fun Map.plus(pairs: Sequence>): Map { /** * Creates a new read-only map by replacing or adding entries to this map from another [map]. */ -public fun Map.plus(map: Map): Map { +public operator fun Map.plus(map: Map): Map { val newMap = this.toLinkedMap() newMap.putAll(map) return newMap @@ -407,42 +407,42 @@ public fun Map.plus(map: Map): Map { /** * Appends or replaces the given [pair] in this mutable map. */ -public fun MutableMap.plusAssign(pair: Pair) { +public operator fun MutableMap.plusAssign(pair: Pair) { put(pair.first, pair.second) } /** * Appends or replaces all pairs from the given collection of [pairs] in this mutable map. */ -public fun MutableMap.plusAssign(pairs: Iterable>) { +public operator fun MutableMap.plusAssign(pairs: Iterable>) { putAll(pairs) } /** * Appends or replaces all pairs from the given array of [pairs] in this mutable map. */ -public fun MutableMap.plusAssign(pairs: Array>) { +public operator fun MutableMap.plusAssign(pairs: Array>) { putAll(*pairs) } /** * Appends or replaces all pairs from the given sequence of [pairs] in this mutable map. */ -public fun MutableMap.plusAssign(pairs: Sequence>) { +public operator fun MutableMap.plusAssign(pairs: Sequence>) { putAll(pairs) } /** * Appends or replaces all entries from the given [map] in this mutable map. */ -public fun MutableMap.plusAssign(map: Map) { +public operator fun MutableMap.plusAssign(map: Map) { putAll(map) } /** * Creates a new read-only map by removing a [key] from this map. */ -public fun Map.minus(key: K): Map { +public operator fun Map.minus(key: K): Map { val result = LinkedHashMap(this) result.minusAssign(key) return result @@ -451,7 +451,7 @@ public fun Map.minus(key: K): Map { /** * Creates a new read-only map by removing a collection of [keys] from this map. */ -public fun Map.minus(keys: Iterable): Map { +public operator fun Map.minus(keys: Iterable): Map { val result = LinkedHashMap(this) result.minusAssign(keys) return result @@ -460,7 +460,7 @@ public fun Map.minus(keys: Iterable): Map { /** * Creates a new read-only map by removing a array of [keys] from this map. */ -public fun Map.minus(keys: Array): Map { +public operator fun Map.minus(keys: Array): Map { val result = LinkedHashMap(this) result.minusAssign(keys) return result @@ -469,7 +469,7 @@ public fun Map.minus(keys: Array): Map { /** * Creates a new read-only map by removing a sequence of [keys] from this map. */ -public fun Map.minus(keys: Sequence): Map { +public operator fun Map.minus(keys: Sequence): Map { val result = LinkedHashMap(this) result.minusAssign(keys) return result @@ -478,27 +478,27 @@ public fun Map.minus(keys: Sequence): Map { /** * Removes the given [key] from this mutable map. */ -public fun MutableMap.minusAssign(key: K) { +public operator fun MutableMap.minusAssign(key: K) { remove(key) } /** * Removes all the given [keys] from this mutable map. */ -public fun MutableMap.minusAssign(keys: Iterable) { +public operator fun MutableMap.minusAssign(keys: Iterable) { for (key in keys) remove(key) } /** * Removes all the given [keys] from this mutable map. */ -public fun MutableMap.minusAssign(keys: Array) { +public operator fun MutableMap.minusAssign(keys: Array) { for (key in keys) remove(key) } /** * Removes all the given [keys] from this mutable map. */ -public fun MutableMap.minusAssign(keys: Sequence) { +public operator fun MutableMap.minusAssign(keys: Sequence) { for (key in keys) remove(key) } diff --git a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt index 5c3c1b9ad6d..ac279460fbc 100644 --- a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt @@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentMap * Allows to use the index operator for storing values in a mutable map. */ // this code is JVM-specific, because JS has native set function -public fun MutableMap.set(key: K, value: V): V? = put(key, value) +public operator fun MutableMap.set(key: K, value: V): V? = put(key, value) /** * getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency. diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt index 8c5006046f5..cffc995cfd4 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt +++ b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt @@ -3,56 +3,56 @@ package kotlin /** * Adds the specified [element] to this mutable collection. */ -public fun MutableCollection.plusAssign(element: T) { +public operator fun MutableCollection.plusAssign(element: T) { this.add(element) } /** * Adds all elements of the given [collection] to this mutable collection. */ -public fun MutableCollection.plusAssign(collection: Iterable) { +public operator fun MutableCollection.plusAssign(collection: Iterable) { this.addAll(collection) } /** * Adds all elements of the given [array] to this mutable collection. */ -public fun MutableCollection.plusAssign(array: Array) { +public operator fun MutableCollection.plusAssign(array: Array) { this.addAll(array) } /** * Adds all elements of the given [sequence] to this mutable collection. */ -public fun MutableCollection.plusAssign(sequence: Sequence) { +public operator fun MutableCollection.plusAssign(sequence: Sequence) { this.addAll(sequence) } /** * Removes a single instance of the specified [element] from this mutable collection. */ -public fun MutableCollection.minusAssign(element: T) { +public operator fun MutableCollection.minusAssign(element: T) { this.remove(element) } /** * Removes all elements contained in the given [collection] from this mutable collection. */ -public fun MutableCollection.minusAssign(collection: Iterable) { +public operator fun MutableCollection.minusAssign(collection: Iterable) { this.removeAll(collection) } /** * Removes all elements contained in the given [array] from this mutable collection. */ -public fun MutableCollection.minusAssign(array: Array) { +public operator fun MutableCollection.minusAssign(array: Array) { this.removeAll(array) } /** * Removes all elements contained in the given [sequence] from this mutable collection. */ -public fun MutableCollection.minusAssign(sequence: Sequence) { +public operator fun MutableCollection.minusAssign(sequence: Sequence) { this.removeAll(sequence) } diff --git a/libraries/stdlib/src/kotlin/collections/Sequence.kt b/libraries/stdlib/src/kotlin/collections/Sequence.kt index f7043a3978a..16d9d9c49a7 100644 --- a/libraries/stdlib/src/kotlin/collections/Sequence.kt +++ b/libraries/stdlib/src/kotlin/collections/Sequence.kt @@ -13,7 +13,7 @@ public interface Sequence { /** * Returns an iterator that returns the values from the sequence. */ - public fun iterator(): Iterator + public operator fun iterator(): Iterator } /** diff --git a/libraries/stdlib/src/kotlin/concurrent/Thread.kt b/libraries/stdlib/src/kotlin/concurrent/Thread.kt index 4a0afa08c06..619041bb90f 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Thread.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Thread.kt @@ -109,7 +109,7 @@ public inline fun ThreadLocal.getOrSet(default: () -> T): T { * execute the given block on the [Executor]. */ @Deprecated("Use Executor.execute(Runnable) instead.") // do not specify ReplaceWith("execute(action)") due to KT-8597 -public fun Executor.invoke(action: () -> Unit) { +public operator fun Executor.invoke(action: () -> Unit) { execute(action) } @@ -118,6 +118,6 @@ public fun Executor.invoke(action: () -> Unit) { * execute the given block on the [ExecutorService]. */ @Deprecated("Use ExecutorService.submit(Callable) instead.") // do not specify ReplaceWith("submit(action)") due to KT-8597 -public fun ExecutorService.invoke(action: () -> T): Future { +public operator fun ExecutorService.invoke(action: () -> T): Future { return submit(action) } diff --git a/libraries/stdlib/src/kotlin/dom/Dom.kt b/libraries/stdlib/src/kotlin/dom/Dom.kt index 0e7055f4371..aff1ac05a2e 100644 --- a/libraries/stdlib/src/kotlin/dom/Dom.kt +++ b/libraries/stdlib/src/kotlin/dom/Dom.kt @@ -116,7 +116,7 @@ public fun NodeList?.toElementList(): List { } /** Searches for elements using the element name, an element ID (if prefixed with dot) or element class (if prefixed with #) */ -public fun Document?.get(selector: String): List { +public operator fun Document?.get(selector: String): List { val root = this?.documentElement return if (root != null) { if (selector == "*") { @@ -140,7 +140,7 @@ public fun Document?.get(selector: String): List { } /** Searches for elements using the element name, an element ID (if prefixed with dot) or element class (if prefixed with #) */ -public fun Element.get(selector: String): List { +public operator fun Element.get(selector: String): List { return if (selector == "*") { elements } else if (selector.startsWith(".")) { @@ -319,16 +319,16 @@ public fun nodesToXmlString(nodes: Iterable, xmlDeclaration: Boolean = fal // Syntax sugar -public fun Node.plus(child: Node?): Node { +public operator fun Node.plus(child: Node?): Node { if (child != null) { this.appendChild(child) } return this } -public fun Element.plus(text: String?): Element = this.addText(text) +public operator fun Element.plus(text: String?): Element = this.addText(text) -public fun Element.plusAssign(text: String?): Element = this.addText(text) +public operator fun Element.plusAssign(text: String?): Element = this.addText(text) // Builder diff --git a/libraries/stdlib/src/kotlin/math/JMath.kt b/libraries/stdlib/src/kotlin/math/JMath.kt index 7490341724e..f5a4eb5e3e7 100644 --- a/libraries/stdlib/src/kotlin/math/JMath.kt +++ b/libraries/stdlib/src/kotlin/math/JMath.kt @@ -6,55 +6,55 @@ import java.math.BigInteger /** * Enables the use of the `+` operator for [BigInteger] instances. */ -public fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other) +public operator fun BigInteger.plus(other: BigInteger) : BigInteger = this.add(other) /** * Enables the use of the `-` operator for [BigInteger] instances. */ -public fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other) +public operator fun BigInteger.minus(other: BigInteger) : BigInteger = this.subtract(other) /** * Enables the use of the `*` operator for [BigInteger] instances. */ -public fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other) +public operator fun BigInteger.times(other: BigInteger) : BigInteger = this.multiply(other) /** * Enables the use of the `/` operator for [BigInteger] instances. */ -public fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other) +public operator fun BigInteger.div(other: BigInteger) : BigInteger = this.divide(other) /** * Enables the use of the unary `-` operator for [BigInteger] instances. */ -public fun BigInteger.minus() : BigInteger = this.negate() +public operator fun BigInteger.minus() : BigInteger = this.negate() /** * Enables the use of the `+` operator for [BigDecimal] instances. */ -public fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other) +public operator fun BigDecimal.plus(other: BigDecimal) : BigDecimal = this.add(other) /** * Enables the use of the `-` operator for [BigDecimal] instances. */ -public fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other) +public operator fun BigDecimal.minus(other: BigDecimal) : BigDecimal = this.subtract(other) /** * Enables the use of the `*` operator for [BigDecimal] instances. */ -public fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other) +public operator fun BigDecimal.times(other: BigDecimal) : BigDecimal = this.multiply(other) /** * Enables the use of the `/` operator for [BigDecimal] instances. */ -public fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other) +public operator fun BigDecimal.div(other: BigDecimal) : BigDecimal = this.divide(other) /** * Enables the use of the `%` operator for [BigDecimal] instances. */ -public fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other) +public operator fun BigDecimal.mod(other: BigDecimal) : BigDecimal = this.remainder(other) /** * Enables the use of the unary `-` operator for [BigDecimal] instances. */ -public fun BigDecimal.minus() : BigDecimal = this.negate() +public operator fun BigDecimal.minus() : BigDecimal = this.negate() diff --git a/libraries/stdlib/src/kotlin/text/Char.kt b/libraries/stdlib/src/kotlin/text/Char.kt index 48353db0b5f..2484b15dc88 100644 --- a/libraries/stdlib/src/kotlin/text/Char.kt +++ b/libraries/stdlib/src/kotlin/text/Char.kt @@ -19,7 +19,7 @@ package kotlin /** * Concatenates this Char and a String. */ -public fun Char.plus(string: String) : String = this.toString() + string +public operator fun Char.plus(string: String) : String = this.toString() + string /** * Returns `true` if this character is equal to the [other] character, optionally ignoring character case. diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index ec357110047..40e1d2db6fa 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -215,7 +215,7 @@ public val String.lastIndex: Int * val c = charSequence[5] * ``` */ -public fun CharSequence.get(index: Int): Char = this.charAt(index) +public operator fun CharSequence.get(index: Int): Char = this.charAt(index) /** * Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index]. @@ -779,7 +779,7 @@ public fun String.lastIndexOf(string: String, startIndex: Int = lastIndex, ignor * * @param ignoreCase `true` to ignore character case when comparing strings. By default `false`. */ -public fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Boolean = +public operator fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Boolean = indexOf(seq.toString(), ignoreCase = ignoreCase) >= 0 @@ -788,7 +788,7 @@ public fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Bool * * @param ignoreCase `true` to ignore character case when comparing characters. By default `false`. */ -public fun String.contains(char: Char, ignoreCase: Boolean = false): Boolean = +public operator fun String.contains(char: Char, ignoreCase: Boolean = false): Boolean = indexOf(char, ignoreCase = ignoreCase) >= 0 // rangesDelimitedBy diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index 2bee9a9c2e3..0861b3612e7 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -411,7 +411,7 @@ public fun String.toCharList(): List = toCharArray().toList() * @param start the start index (inclusive). * @param end the end index (exclusive). */ -public fun CharSequence.get(start: Int, end: Int): CharSequence = subSequence(start, end) +public operator fun CharSequence.get(start: Int, end: Int): CharSequence = subSequence(start, end) /** * Encodes the contents of this string using the specified character set and returns the resulting byte array. diff --git a/libraries/stdlib/src/kotlin/text/regex/Regex.kt b/libraries/stdlib/src/kotlin/text/regex/Regex.kt index c4ac373db74..e2d024174b0 100644 --- a/libraries/stdlib/src/kotlin/text/regex/Regex.kt +++ b/libraries/stdlib/src/kotlin/text/regex/Regex.kt @@ -35,7 +35,7 @@ public interface MatchGroupCollection : Collection { * Groups are indexed from 1 to the count of groups in the regular expression. A group with the index 0 * corresponds to the entire match. */ - public fun get(index: Int): MatchGroup? + public operator fun get(index: Int): MatchGroup? // TODO: Provide get(name: String) on JVM 7+ } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index ca1c738e996..8732a83bde1 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -6,6 +6,8 @@ fun elements(): List { val templates = arrayListOf() 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 { 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) { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt index e06a1579cfd..a743e5a6ec4 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt @@ -105,6 +105,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp val inline = FamilyProperty() val typeParams = ArrayList() val returns = FamilyProperty() + val operator = FamilyProperty() val body = object : FamilyProperty() { 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 ") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 8e2a0f7f31b..2070d0f39cd 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -6,6 +6,8 @@ fun generators(): List { val templates = arrayListOf() 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") @@ -49,6 +51,8 @@ fun generators(): List { } templates add f("plus(collection: Iterable)") { + 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") @@ -104,6 +108,8 @@ fun generators(): List { } templates add f("plus(array: Array)") { + 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") @@ -151,6 +157,8 @@ fun generators(): List { templates add f("plus(sequence: Sequence)") { + 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") @@ -199,6 +207,8 @@ fun generators(): List { } 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") @@ -236,6 +246,8 @@ fun generators(): List { templates add f("minus(collection: Iterable)") { + 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") @@ -289,6 +301,8 @@ fun generators(): List { } templates add f("minus(array: Array)") { + 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") @@ -331,6 +345,8 @@ fun generators(): List { } templates add f("minus(sequence: Sequence)") { + 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") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt index 54d969d102b..e4440303988 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt @@ -118,6 +118,8 @@ fun ranges(): List { .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) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 7fd938caead..4e7fdac0d63 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -6,6 +6,8 @@ fun specialJVM(): List { val templates = arrayListOf() 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 { } templates add f("plus(collection: Collection)") { + 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 { } templates add f("plus(array: SELF)") { + operator(true) + only(InvariantArraysOfObjects, ArraysOfPrimitives) customSignature(InvariantArraysOfObjects) { "plus(array: Array)" } doc { "Returns an array containing all elements of the original array and then all elements of the given [array]." }