diff --git a/core/builtins/native/kotlin/Arrays.kt b/core/builtins/native/kotlin/Arrays.kt index 247932b79a9..90d1f0f4b42 100644 --- a/core/builtins/native/kotlin/Arrays.kt +++ b/core/builtins/native/kotlin/Arrays.kt @@ -19,7 +19,7 @@ package kotlin /** - * An array of bytes. When targeting the JVM, instances of this class are represented as byte[]. + * An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class ByteArray(size: Int) : Cloneable { @@ -38,7 +38,7 @@ public class ByteArray(size: Int) : Cloneable { } /** - * An array of chars. When targeting the JVM, instances of this class are represented as char[]. + * An array of chars. When targeting the JVM, instances of this class are represented as `char[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class CharArray(size: Int) : Cloneable { @@ -57,7 +57,7 @@ public class CharArray(size: Int) : Cloneable { } /** - * An array of shorts. When targeting the JVM, instances of this class are represented as short[]. + * An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class ShortArray(size: Int) : Cloneable { @@ -76,7 +76,7 @@ public class ShortArray(size: Int) : Cloneable { } /** - * An array of ints. When targeting the JVM, instances of this class are represented as int[]. + * An array of ints. When targeting the JVM, instances of this class are represented as `int[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class IntArray(size: Int) : Cloneable { @@ -95,7 +95,7 @@ public class IntArray(size: Int) : Cloneable { } /** - * An array of longs. When targeting the JVM, instances of this class are represented as long[]. + * An array of longs. When targeting the JVM, instances of this class are represented as `long[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class LongArray(size: Int) : Cloneable { @@ -114,7 +114,7 @@ public class LongArray(size: Int) : Cloneable { } /** - * An array of floats. When targeting the JVM, instances of this class are represented as float[]. + * An array of floats. When targeting the JVM, instances of this class are represented as `float[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class FloatArray(size: Int) : Cloneable { @@ -133,7 +133,7 @@ public class FloatArray(size: Int) : Cloneable { } /** - * An array of doubles. When targeting the JVM, instances of this class are represented as double[]. + * An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ public class DoubleArray(size: Int) : Cloneable { @@ -152,7 +152,7 @@ public class DoubleArray(size: Int) : Cloneable { } /** - * An array of booleans. When targeting the JVM, instances of this class are represented as boolean[]. + * An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`. * @constructor Creates a new array of the specified [size], with all elements initialized to false. */ public class BooleanArray(size: Int) : Cloneable { diff --git a/core/builtins/native/kotlin/Boolean.kt b/core/builtins/native/kotlin/Boolean.kt index d0fd5d57d4e..4dde62d2b01 100644 --- a/core/builtins/native/kotlin/Boolean.kt +++ b/core/builtins/native/kotlin/Boolean.kt @@ -21,12 +21,24 @@ package kotlin * represented as values of the primitive type `boolean`. */ public class Boolean private () : Comparable { + /** + * Returns the inverse of this boolean. + */ public fun not(): Boolean + /** + * Performs a logical `and` operation between this Boolean and the [other] one. + */ public fun and(other: Boolean): Boolean + /** + * Performs a logical `or` operation between this Boolean and the [other] one. + */ public fun or(other: Boolean): Boolean + /** + * Performs a logical `xor` operation between this Boolean and the [other] one. + */ public fun xor(other: Boolean): Boolean public override fun compareTo(other: Boolean): Int diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index 7a94b2b7b57..d441ae772bf 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -25,65 +25,146 @@ package kotlin public class Byte private () : Number, Comparable { default object {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Int + /** Adds the other value to this value. */ public fun plus(other: Char): Int + /** Adds the other value to this value. */ public fun plus(other: Short): Int + /** Adds the other value to this value. */ public fun plus(other: Int): Int + /** Adds the other value to this value. */ public fun plus(other: Long): Long + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int + /** Subtracts the other value from this value. */ public fun minus(other: Char): Int + /** Subtracts the other value from this value. */ public fun minus(other: Short): Int + /** Subtracts the other value from this value. */ public fun minus(other: Int): Int + /** Subtracts the other value from this value. */ public fun minus(other: Long): Long + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Int + /** Multiplies this value by the other value. */ public fun times(other: Char): Int + /** Multiplies this value by the other value. */ public fun times(other: Short): Int + /** Multiplies this value by the other value. */ public fun times(other: Int): Int + /** Multiplies this value by the other value. */ public fun times(other: Long): Long + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Int + /** Divides this value by the other value. */ public fun div(other: Char): Int + /** Divides this value by the other value. */ public fun div(other: Short): Int + /** Divides this value by the other value. */ public fun div(other: Int): Int + /** Divides this value by the other value. */ public fun div(other: Long): Long + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Byte + /** Decrements this value. */ public fun dec(): Byte + /** Returns this value. */ public fun plus(): Int + /** Returns the negative of this value. */ public fun minus(): Int + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): ByteRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): CharRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): ShortRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte @@ -102,63 +183,141 @@ public class Byte private () : Number, Comparable { public class Char private () : Comparable { default object {} +/** + * Compares the character code of this character 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: 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: Char): Int +/** + * Compares the character code of this character 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 +/** + * Compares the character code of this character 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 +/** + * Compares the character code of this character 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 +/** + * Compares the character code of this character 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 +/** + * Compares the character code of this character 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Int + /** Adds the other value to this value. */ public fun plus(other: Short): Int + /** Adds the other value to this value. */ public fun plus(other: Int): Int + /** Adds the other value to this value. */ public fun plus(other: Long): Long + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int + /** Subtracts the other value from this value. */ public fun minus(other: Char): Int + /** Subtracts the other value from this value. */ public fun minus(other: Short): Int + /** Subtracts the other value from this value. */ public fun minus(other: Int): Int + /** Subtracts the other value from this value. */ public fun minus(other: Long): Long + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Int + /** Multiplies this value by the other value. */ public fun times(other: Short): Int + /** Multiplies this value by the other value. */ public fun times(other: Int): Int + /** Multiplies this value by the other value. */ public fun times(other: Long): Long + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Int + /** Divides this value by the other value. */ public fun div(other: Short): Int + /** Divides this value by the other value. */ public fun div(other: Int): Int + /** Divides this value by the other value. */ public fun div(other: Long): Long + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Char + /** Decrements this value. */ public fun dec(): Char + /** Returns this value. */ public fun plus(): Int + /** Returns the negative of this value. */ public fun minus(): Int + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): CharRange + /** Returns the value of this character as a `Byte`. */ public override fun toByte(): Byte + /** Returns the value of this character as a `Char`. */ public override fun toChar(): Char + /** Returns the value of this character as a `Short`. */ public override fun toShort(): Short + /** Returns the value of this character as a `Int`. */ public override fun toInt(): Int + /** Returns the value of this character as a `Long`. */ public override fun toLong(): Long + /** Returns the value of this character as a `Float`. */ public override fun toFloat(): Float + /** Returns the value of this character as a `Double`. */ public override fun toDouble(): Double } @@ -169,65 +328,146 @@ public class Char private () : Comparable { public class Short private () : Number, Comparable { default object {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Int + /** Adds the other value to this value. */ public fun plus(other: Char): Int + /** Adds the other value to this value. */ public fun plus(other: Short): Int + /** Adds the other value to this value. */ public fun plus(other: Int): Int + /** Adds the other value to this value. */ public fun plus(other: Long): Long + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int + /** Subtracts the other value from this value. */ public fun minus(other: Char): Int + /** Subtracts the other value from this value. */ public fun minus(other: Short): Int + /** Subtracts the other value from this value. */ public fun minus(other: Int): Int + /** Subtracts the other value from this value. */ public fun minus(other: Long): Long + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Int + /** Multiplies this value by the other value. */ public fun times(other: Char): Int + /** Multiplies this value by the other value. */ public fun times(other: Short): Int + /** Multiplies this value by the other value. */ public fun times(other: Int): Int + /** Multiplies this value by the other value. */ public fun times(other: Long): Long + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Int + /** Divides this value by the other value. */ public fun div(other: Char): Int + /** Divides this value by the other value. */ public fun div(other: Short): Int + /** Divides this value by the other value. */ public fun div(other: Int): Int + /** Divides this value by the other value. */ public fun div(other: Long): Long + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Short + /** Decrements this value. */ public fun dec(): Short + /** Returns this value. */ public fun plus(): Int + /** Returns the negative of this value. */ public fun minus(): Int + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): ShortRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): ShortRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): ShortRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte @@ -246,73 +486,161 @@ public class Short private () : Number, Comparable { public class Int private () : Number, Comparable { default object {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Int + /** Adds the other value to this value. */ public fun plus(other: Char): Int + /** Adds the other value to this value. */ public fun plus(other: Short): Int + /** Adds the other value to this value. */ public fun plus(other: Int): Int + /** Adds the other value to this value. */ public fun plus(other: Long): Long + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int + /** Subtracts the other value from this value. */ public fun minus(other: Char): Int + /** Subtracts the other value from this value. */ public fun minus(other: Short): Int + /** Subtracts the other value from this value. */ public fun minus(other: Int): Int + /** Subtracts the other value from this value. */ public fun minus(other: Long): Long + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Int + /** Multiplies this value by the other value. */ public fun times(other: Char): Int + /** Multiplies this value by the other value. */ public fun times(other: Short): Int + /** Multiplies this value by the other value. */ public fun times(other: Int): Int + /** Multiplies this value by the other value. */ public fun times(other: Long): Long + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Int + /** Divides this value by the other value. */ public fun div(other: Char): Int + /** Divides this value by the other value. */ public fun div(other: Short): Int + /** Divides this value by the other value. */ public fun div(other: Int): Int + /** Divides this value by the other value. */ public fun div(other: Long): Long + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Int + /** Decrements this value. */ public fun dec(): Int + /** Returns this value. */ public fun plus(): Int + /** Returns the negative of this value. */ public fun minus(): Int + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange + /** Shifts this value left by [bits]. */ public fun shl(bits: Int): Int + /** Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit. */ public fun shr(bits: Int): Int + /** Shifts this value right by [bits], filling the leftmost bits with zeros. */ public fun ushr(bits: Int): Int + /** Performs a bitwise AND operation between the two values. */ public fun and(other: Int): Int + /** Performs a bitwise OR operation between the two values. */ public fun or(other: Int): Int + /** Performs a bitwise XOR operation between the two values. */ public fun xor(other: Int): Int + /** Inverts the bits in this value/ */ public fun inv(): Int public override fun toByte(): Byte @@ -331,73 +659,161 @@ public class Int private () : Number, Comparable { public class Long private () : Number, Comparable { default object {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Long + /** Adds the other value to this value. */ public fun plus(other: Char): Long + /** Adds the other value to this value. */ public fun plus(other: Short): Long + /** Adds the other value to this value. */ public fun plus(other: Int): Long + /** Adds the other value to this value. */ public fun plus(other: Long): Long + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Long + /** Subtracts the other value from this value. */ public fun minus(other: Char): Long + /** Subtracts the other value from this value. */ public fun minus(other: Short): Long + /** Subtracts the other value from this value. */ public fun minus(other: Int): Long + /** Subtracts the other value from this value. */ public fun minus(other: Long): Long + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Long + /** Multiplies this value by the other value. */ public fun times(other: Char): Long + /** Multiplies this value by the other value. */ public fun times(other: Short): Long + /** Multiplies this value by the other value. */ public fun times(other: Int): Long + /** Multiplies this value by the other value. */ public fun times(other: Long): Long + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Long + /** Divides this value by the other value. */ public fun div(other: Char): Long + /** Divides this value by the other value. */ public fun div(other: Short): Long + /** Divides this value by the other value. */ public fun div(other: Int): Long + /** Divides this value by the other value. */ public fun div(other: Long): Long + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Long + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Long + /** Decrements this value. */ public fun dec(): Long + /** Returns this value. */ public fun plus(): Long + /** Returns the negative of this value. */ public fun minus(): Long + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): LongRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange + /** Shifts this value left by [bits]. */ public fun shl(bits: Int): Long + /** Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit. */ public fun shr(bits: Int): Long + /** Shifts this value right by [bits], filling the leftmost bits with zeros. */ public fun ushr(bits: Int): Long + /** Performs a bitwise AND operation between the two values. */ public fun and(other: Long): Long + /** Performs a bitwise OR operation between the two values. */ public fun or(other: Long): Long + /** Performs a bitwise XOR operation between the two values. */ public fun xor(other: Long): Long + /** Inverts the bits in this value/ */ public fun inv(): Long public override fun toByte(): Byte @@ -416,65 +832,146 @@ public class Long private () : Number, Comparable { public class Float private () : Number, Comparable { default object : FloatingPointConstants {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Float + /** Adds the other value to this value. */ public fun plus(other: Char): Float + /** Adds the other value to this value. */ public fun plus(other: Short): Float + /** Adds the other value to this value. */ public fun plus(other: Int): Float + /** Adds the other value to this value. */ public fun plus(other: Long): Float + /** Adds the other value to this value. */ public fun plus(other: Float): Float + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Float + /** Subtracts the other value from this value. */ public fun minus(other: Char): Float + /** Subtracts the other value from this value. */ public fun minus(other: Short): Float + /** Subtracts the other value from this value. */ public fun minus(other: Int): Float + /** Subtracts the other value from this value. */ public fun minus(other: Long): Float + /** Subtracts the other value from this value. */ public fun minus(other: Float): Float + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Float + /** Multiplies this value by the other value. */ public fun times(other: Char): Float + /** Multiplies this value by the other value. */ public fun times(other: Short): Float + /** Multiplies this value by the other value. */ public fun times(other: Int): Float + /** Multiplies this value by the other value. */ public fun times(other: Long): Float + /** Multiplies this value by the other value. */ public fun times(other: Float): Float + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Float + /** Divides this value by the other value. */ public fun div(other: Char): Float + /** Divides this value by the other value. */ public fun div(other: Short): Float + /** Divides this value by the other value. */ public fun div(other: Int): Float + /** Divides this value by the other value. */ public fun div(other: Long): Float + /** Divides this value by the other value. */ public fun div(other: Float): Float + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Float + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Float + /** Decrements this value. */ public fun dec(): Float + /** Returns this value. */ public fun plus(): Float + /** Returns the negative of this value. */ public fun minus(): Float + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): FloatRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte @@ -493,65 +990,146 @@ public class Float private () : Number, Comparable { public class Double private () : Number, Comparable { default object : FloatingPointConstants {} +/** + * 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: Byte): Int +/** + * Compares this value with the character code of the specified character 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: Char): 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 +/** + * 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 +/** + * 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 +/** + * 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 +/** + * 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 + /** Adds the other value to this value. */ public fun plus(other: Byte): Double + /** Adds the other value to this value. */ public fun plus(other: Char): Double + /** Adds the other value to this value. */ public fun plus(other: Short): Double + /** Adds the other value to this value. */ public fun plus(other: Int): Double + /** Adds the other value to this value. */ public fun plus(other: Long): Double + /** Adds the other value to this value. */ public fun plus(other: Float): Double + /** Adds the other value to this value. */ public fun plus(other: Double): Double + /** Subtracts the other value from this value. */ public fun minus(other: Byte): Double + /** Subtracts the other value from this value. */ public fun minus(other: Char): Double + /** Subtracts the other value from this value. */ public fun minus(other: Short): Double + /** Subtracts the other value from this value. */ public fun minus(other: Int): Double + /** Subtracts the other value from this value. */ public fun minus(other: Long): Double + /** Subtracts the other value from this value. */ public fun minus(other: Float): Double + /** Subtracts the other value from this value. */ public fun minus(other: Double): Double + /** Multiplies this value by the other value. */ public fun times(other: Byte): Double + /** Multiplies this value by the other value. */ public fun times(other: Char): Double + /** Multiplies this value by the other value. */ public fun times(other: Short): Double + /** Multiplies this value by the other value. */ public fun times(other: Int): Double + /** Multiplies this value by the other value. */ public fun times(other: Long): Double + /** Multiplies this value by the other value. */ public fun times(other: Float): Double + /** Multiplies this value by the other value. */ public fun times(other: Double): Double + /** Divides this value by the other value. */ public fun div(other: Byte): Double + /** Divides this value by the other value. */ public fun div(other: Char): Double + /** Divides this value by the other value. */ public fun div(other: Short): Double + /** Divides this value by the other value. */ public fun div(other: Int): Double + /** Divides this value by the other value. */ public fun div(other: Long): Double + /** Divides this value by the other value. */ public fun div(other: Float): Double + /** Divides this value by the other value. */ public fun div(other: Double): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Char): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Long): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Float): Double + /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Double): Double + /** Increments this value. */ public fun inc(): Double + /** Decrements this value. */ public fun dec(): Double + /** Returns this value. */ public fun plus(): Double + /** Returns the negative of this value. */ public fun minus(): Double + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Long): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Float): DoubleRange + /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index a189279a794..4ae8756cd5a 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -26,13 +26,13 @@ public annotation class data /** * Marks the annotated class, function or property as deprecated. - * @param value the message explaining the deprecation and recommending an alternative API to use. + * @property value the message explaining the deprecation and recommending an alternative API to use. */ public annotation class deprecated(val value: String) /** * Suppresses the given compilation warnings in the annotated element. - * @param names names of the compiler diagnostics to suppress. + * @property names names of the compiler diagnostics to suppress. */ public annotation class suppress(vararg val names: String) diff --git a/core/builtins/src/kotlin/ExtensionFunctions.kt b/core/builtins/src/kotlin/ExtensionFunctions.kt index ce2925b6bcb..330650d6eed 100644 --- a/core/builtins/src/kotlin/ExtensionFunctions.kt +++ b/core/builtins/src/kotlin/ExtensionFunctions.kt @@ -18,72 +18,118 @@ package kotlin +/** An extension function that takes 0 arguments. */ public trait ExtensionFunction0 { + /** Invokes the function. */ public fun T.invoke(): R } +/** An extension function that takes 1 argument. */ public trait ExtensionFunction1 { + /** Invokes the function with the specified argument. */ public fun T.invoke(p1: P1): R } +/** An extension function that takes 2 arguments. */ public trait ExtensionFunction2 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2): R } +/** An extension function that takes 3 arguments. */ public trait ExtensionFunction3 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3): R } +/** An extension function that takes 4 arguments. */ public trait ExtensionFunction4 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4): R } +/** An extension function that takes 5 arguments. */ public trait ExtensionFunction5 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R } +/** An extension function that takes 6 arguments. */ public trait ExtensionFunction6 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R } +/** An extension function that takes 7 arguments. */ public trait ExtensionFunction7 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R } +/** An extension function that takes 8 arguments. */ public trait ExtensionFunction8 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R } +/** An extension function that takes 9 arguments. */ public trait ExtensionFunction9 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R } +/** An extension function that takes 10 arguments. */ public trait ExtensionFunction10 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R } +/** An extension function that takes 11 arguments. */ public trait ExtensionFunction11 { + /** Invokes the function with the specified arguments. */ public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R } +/** An extension function that takes 12 arguments. */ public trait ExtensionFunction12 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 13 arguments. */ public trait ExtensionFunction13 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 14 arguments. */ public trait ExtensionFunction14 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 15 arguments. */ public trait ExtensionFunction15 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 16 arguments. */ public trait ExtensionFunction16 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 17 arguments. */ public trait ExtensionFunction17 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 18 arguments. */ public trait ExtensionFunction18 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 19 arguments. */ public trait ExtensionFunction19 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 20 arguments. */ public trait ExtensionFunction20 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 21 arguments. */ public trait ExtensionFunction21 { + /** Invokes the function with the specified arguments. */ public fun T.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 } +/** An extension function that takes 22 arguments. */ public trait ExtensionFunction22 { + /** Invokes the function with the specified arguments. */ public fun T.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/builtins/src/kotlin/FloatingPointConstants.kt b/core/builtins/src/kotlin/FloatingPointConstants.kt index 42963f0a022..dfe93baed24 100644 --- a/core/builtins/src/kotlin/FloatingPointConstants.kt +++ b/core/builtins/src/kotlin/FloatingPointConstants.kt @@ -16,8 +16,22 @@ package kotlin +/** + * Holder for special values of floating point types. + */ public trait FloatingPointConstants { + /** + * A constant holding the positive infinity value. + */ public val POSITIVE_INFINITY: T + + /** + * A constant holding the negative infinity value. + */ public val NEGATIVE_INFINITY: T + + /** + * A constant holding the "not a number" value. + */ public val NaN: T } \ No newline at end of file diff --git a/core/builtins/src/kotlin/Functions.kt b/core/builtins/src/kotlin/Functions.kt index d65fc085e3f..18a16c56e1c 100644 --- a/core/builtins/src/kotlin/Functions.kt +++ b/core/builtins/src/kotlin/Functions.kt @@ -18,72 +18,118 @@ package kotlin +/** A function that takes 0 arguments. */ public trait Function0 { + /** Invokes the function. */ public fun invoke(): R } +/** A function that takes 1 argument. */ public trait Function1 { + /** Invokes the function with the specified argument. */ public fun invoke(p1: P1): R } +/** A function that takes 2 arguments. */ public trait Function2 { + /** Invokes the function with the specified arguments. */ public fun invoke(p1: P1, p2: P2): R } +/** A function that takes 3 arguments. */ public trait Function3 { + /** Invokes the function with the specified arguments. */ public fun invoke(p1: P1, p2: P2, p3: P3): R } +/** A function that takes 4 arguments. */ public trait Function4 { + /** Invokes the function with the specified arguments. */ public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R } +/** A function that takes 5 arguments. */ public trait Function5 { + /** Invokes the function with the specified arguments. */ public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R } +/** A function that takes 6 arguments. */ public trait Function6 { + /** Invokes the function with the specified arguments. */ public fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R } +/** A function that takes 7 arguments. */ public trait Function7 { + /** 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 } +/** A function that takes 8 arguments. */ public trait Function8 { + /** 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 } +/** A function that takes 9 arguments. */ public trait Function9 { + /** 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 } +/** A function that takes 10 arguments. */ public trait Function10 { + /** 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 } +/** A function that takes 11 arguments. */ public trait Function11 { + /** 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 } +/** A function that takes 12 arguments. */ public trait Function12 { + /** 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 } +/** A function that takes 13 arguments. */ public trait Function13 { + /** 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 } +/** A function that takes 14 arguments. */ public trait Function14 { + /** 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 } +/** A function that takes 15 arguments. */ public trait Function15 { + /** 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 } +/** A function that takes 16 arguments. */ public trait Function16 { + /** 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 } +/** A function that takes 17 arguments. */ public trait Function17 { + /** 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 } +/** A function that takes 18 arguments. */ public trait Function18 { + /** 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 } +/** A function that takes 19 arguments. */ public trait Function19 { + /** 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 } +/** A function that takes 20 arguments. */ public trait Function20 { + /** 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 } +/** A function that takes 21 arguments. */ public trait Function21 { + /** 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 } +/** A function that takes 22 arguments. */ public trait Function22 { + /** 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 } diff --git a/core/builtins/src/kotlin/Inline.kt b/core/builtins/src/kotlin/Inline.kt index 6b3cefa6d16..26b265d7c21 100644 --- a/core/builtins/src/kotlin/Inline.kt +++ b/core/builtins/src/kotlin/Inline.kt @@ -27,6 +27,9 @@ public annotation class noinline * calling functions. Inline functions can use reified type parameters, and lambdas passed to inline * functions can contain non-local returns. * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/inline-functions.html) for more information. + * + * @property strategy the [InlineStrategy] to use for inlining this function. + * * @see noinline * @see inlineOptions */ @@ -55,6 +58,8 @@ public enum class InlineStrategy { * receiving function are allowed to use non-local control flow statements. Lambdas which are called from * a different execution context (for example, from an object contained in the receiving function) * are restricted to local control flow statements. + * + * @property value the inlining options selected for the annotated function parameter. */ public annotation class inlineOptions(vararg val value: InlineOption) diff --git a/core/builtins/src/kotlin/Iterators.kt b/core/builtins/src/kotlin/Iterators.kt index e24d90c5169..dc03217efee 100644 --- a/core/builtins/src/kotlin/Iterators.kt +++ b/core/builtins/src/kotlin/Iterators.kt @@ -18,7 +18,7 @@ package kotlin -/** An iterator over a sequence of values of type Byte. */ +/** An iterator over a sequence of values of type `Byte`. */ public abstract class ByteIterator : Iterator { override final fun next() = nextByte() @@ -26,7 +26,7 @@ public abstract class ByteIterator : Iterator { public abstract fun nextByte(): Byte } -/** An iterator over a sequence of values of type Char. */ +/** An iterator over a sequence of values of type `Char`. */ public abstract class CharIterator : Iterator { override final fun next() = nextChar() @@ -34,7 +34,7 @@ public abstract class CharIterator : Iterator { public abstract fun nextChar(): Char } -/** An iterator over a sequence of values of type Short. */ +/** An iterator over a sequence of values of type `Short`. */ public abstract class ShortIterator : Iterator { override final fun next() = nextShort() @@ -42,7 +42,7 @@ public abstract class ShortIterator : Iterator { public abstract fun nextShort(): Short } -/** An iterator over a sequence of values of type Int. */ +/** An iterator over a sequence of values of type `Int`. */ public abstract class IntIterator : Iterator { override final fun next() = nextInt() @@ -50,7 +50,7 @@ public abstract class IntIterator : Iterator { public abstract fun nextInt(): Int } -/** An iterator over a sequence of values of type Long. */ +/** An iterator over a sequence of values of type `Long`. */ public abstract class LongIterator : Iterator { override final fun next() = nextLong() @@ -58,7 +58,7 @@ public abstract class LongIterator : Iterator { public abstract fun nextLong(): Long } -/** An iterator over a sequence of values of type Float. */ +/** An iterator over a sequence of values of type `Float`. */ public abstract class FloatIterator : Iterator { override final fun next() = nextFloat() @@ -66,7 +66,7 @@ public abstract class FloatIterator : Iterator { public abstract fun nextFloat(): Float } -/** An iterator over a sequence of values of type Double. */ +/** An iterator over a sequence of values of type `Double`. */ public abstract class DoubleIterator : Iterator { override final fun next() = nextDouble() @@ -74,7 +74,7 @@ public abstract class DoubleIterator : Iterator { public abstract fun nextDouble(): Double } -/** An iterator over a sequence of values of type Boolean. */ +/** An iterator over a sequence of values of type `Boolean`. */ public abstract class BooleanIterator : Iterator { override final fun next() = nextBoolean() diff --git a/core/builtins/src/kotlin/ProgressionIterators.kt b/core/builtins/src/kotlin/ProgressionIterators.kt index d61c3288f2d..471e9fcb50f 100644 --- a/core/builtins/src/kotlin/ProgressionIterators.kt +++ b/core/builtins/src/kotlin/ProgressionIterators.kt @@ -20,7 +20,10 @@ package kotlin import kotlin.internal.getProgressionFinalElement -/** An iterator over a progression of values of type Byte. */ +/** + * An iterator over a progression of values of type `Byte`. + * @property increment the number by which the value is incremented on each step. + */ class ByteProgressionIterator(start: Byte, end: Byte, val increment: Int) : ByteIterator() { private var next = start.toInt() private val finalElement: Byte = getProgressionFinalElement(start.toInt(), end.toInt(), increment).toByte() @@ -40,7 +43,10 @@ class ByteProgressionIterator(start: Byte, end: Byte, val increment: Int) : Byte } } -/** An iterator over a progression of values of type Char. */ +/** + * An iterator over a progression of values of type `Char`. + * @property increment the number by which the value is incremented on each step. + */ class CharProgressionIterator(start: Char, end: Char, val increment: Int) : CharIterator() { private var next = start.toInt() private val finalElement: Char = getProgressionFinalElement(start.toInt(), end.toInt(), increment).toChar() @@ -60,7 +66,10 @@ class CharProgressionIterator(start: Char, end: Char, val increment: Int) : Char } } -/** An iterator over a progression of values of type Short. */ +/** + * An iterator over a progression of values of type `Short`. + * @property increment the number by which the value is incremented on each step. + */ class ShortProgressionIterator(start: Short, end: Short, val increment: Int) : ShortIterator() { private var next = start.toInt() private val finalElement: Short = getProgressionFinalElement(start.toInt(), end.toInt(), increment).toShort() @@ -80,7 +89,10 @@ class ShortProgressionIterator(start: Short, end: Short, val increment: Int) : S } } -/** An iterator over a progression of values of type Int. */ +/** + * An iterator over a progression of values of type `Int`. + * @property increment the number by which the value is incremented on each step. + */ class IntProgressionIterator(start: Int, end: Int, val increment: Int) : IntIterator() { private var next = start private val finalElement: Int = getProgressionFinalElement(start, end, increment) @@ -100,7 +112,10 @@ class IntProgressionIterator(start: Int, end: Int, val increment: Int) : IntIter } } -/** An iterator over a progression of values of type Long. */ +/** + * An iterator over a progression of values of type `Long`. + * @property increment the number by which the value is incremented on each step. + */ class LongProgressionIterator(start: Long, end: Long, val increment: Long) : LongIterator() { private var next = start private val finalElement: Long = getProgressionFinalElement(start, end, increment) @@ -120,7 +135,10 @@ class LongProgressionIterator(start: Long, end: Long, val increment: Long) : Lon } } -/** An iterator over a progression of values of type Float. */ +/** + * An iterator over a progression of values of type `Float`. + * @property increment the number by which the value is incremented on each step. + */ class FloatProgressionIterator(start: Float, val end: Float, val increment: Float) : FloatIterator() { private var next = start @@ -133,7 +151,10 @@ class FloatProgressionIterator(start: Float, val end: Float, val increment: Floa } } -/** An iterator over a progression of values of type Double. */ +/** + * An iterator over a progression of values of type `Double`. + * @property increment the number by which the value is incremented on each step. + */ class DoubleProgressionIterator(start: Double, val end: Double, val increment: Double) : DoubleIterator() { private var next = start diff --git a/core/builtins/src/kotlin/Progressions.kt b/core/builtins/src/kotlin/Progressions.kt index d422f3a1877..c2bc8b1d9da 100644 --- a/core/builtins/src/kotlin/Progressions.kt +++ b/core/builtins/src/kotlin/Progressions.kt @@ -19,7 +19,7 @@ package kotlin /** - * A progression of values of type Byte. + * A progression of values of type `Byte`. */ public class ByteProgression( override val start: Byte, @@ -46,7 +46,7 @@ public class ByteProgression( } /** - * A progression of values of type Char. + * A progression of values of type `Char`. */ public class CharProgression( override val start: Char, @@ -73,7 +73,7 @@ public class CharProgression( } /** - * A progression of values of type Short. + * A progression of values of type `Short`. */ public class ShortProgression( override val start: Short, @@ -100,7 +100,7 @@ public class ShortProgression( } /** - * A progression of values of type Int. + * A progression of values of type `Int`. */ public class IntProgression( override val start: Int, @@ -127,7 +127,7 @@ public class IntProgression( } /** - * A progression of values of type Long. + * A progression of values of type `Long`. */ public class LongProgression( override val start: Long, @@ -154,7 +154,7 @@ public class LongProgression( } /** - * A progression of values of type Float. + * A progression of values of type `Float`. */ public class FloatProgression( override val start: Float, @@ -182,7 +182,7 @@ public class FloatProgression( } /** - * A progression of values of type Double. + * A progression of values of type `Double`. */ public class DoubleProgression( override val start: Double, diff --git a/core/builtins/src/kotlin/PropertyMetadata.kt b/core/builtins/src/kotlin/PropertyMetadata.kt index 8b6174f7873..f7c473a280d 100644 --- a/core/builtins/src/kotlin/PropertyMetadata.kt +++ b/core/builtins/src/kotlin/PropertyMetadata.kt @@ -26,4 +26,7 @@ public trait PropertyMetadata { public val name: String } +/** + * @suppress + */ public class PropertyMetadataImpl(override val name: String): PropertyMetadata diff --git a/core/builtins/src/kotlin/Ranges.kt b/core/builtins/src/kotlin/Ranges.kt index 2d0506ba49d..b6569ee97b9 100644 --- a/core/builtins/src/kotlin/Ranges.kt +++ b/core/builtins/src/kotlin/Ranges.kt @@ -19,7 +19,7 @@ package kotlin /** - * A range of values of type Byte. + * A range of values of type `Byte`. */ public class ByteRange(override val start: Byte, override val end: Byte) : Range, Progression { override val increment: Int @@ -45,7 +45,7 @@ public class ByteRange(override val start: Byte, override val end: Byte) : Range } /** - * A range of values of type Char. + * A range of values of type `Char`. */ public class CharRange(override val start: Char, override val end: Char) : Range, Progression { override val increment: Int @@ -71,7 +71,7 @@ public class CharRange(override val start: Char, override val end: Char) : Range } /** - * A range of values of type Short. + * A range of values of type `Short`. */ public class ShortRange(override val start: Short, override val end: Short) : Range, Progression { override val increment: Int @@ -97,7 +97,7 @@ public class ShortRange(override val start: Short, override val end: Short) : Ra } /** - * A range of values of type Int. + * A range of values of type `Int`. */ public class IntRange(override val start: Int, override val end: Int) : Range, Progression { override val increment: Int @@ -123,7 +123,7 @@ public class IntRange(override val start: Int, override val end: Int) : Range, Progression { override val increment: Long @@ -149,7 +149,7 @@ public class LongRange(override val start: Long, override val end: Long) : Range } /** - * A range of values of type Float. + * A range of values of type `Float`. */ public class FloatRange(override val start: Float, override val end: Float) : Range, Progression { override val increment: Float @@ -175,7 +175,7 @@ public class FloatRange(override val start: Float, override val end: Float) : Ra } /** - * A range of values of type Double. + * A range of values of type `Double`. */ public class DoubleRange(override val start: Double, override val end: Double) : Range, Progression { override val increment: Double diff --git a/core/builtins/src/kotlin/Unit.kt b/core/builtins/src/kotlin/Unit.kt index b0990ff6478..6ee042b413f 100644 --- a/core/builtins/src/kotlin/Unit.kt +++ b/core/builtins/src/kotlin/Unit.kt @@ -16,6 +16,9 @@ package kotlin +/** + * The type with only one value: the Unit object. This type corresponds to the `void` type in Java. + */ public object Unit { override fun toString() = "kotlin.Unit" } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt index df96e1752bf..e34f7c12bbb 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/arrays.kt @@ -29,7 +29,7 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) { val s = kind.capitalized val defaultValue = when(kind) { PrimitiveType.BOOLEAN -> "false"; else -> "zero" } out.println("/**") - out.println(" * An array of ${typeLower}s. When targeting the JVM, instances of this class are represented as ${typeLower}[].") + out.println(" * An array of ${typeLower}s. When targeting the JVM, instances of this class are represented as `${typeLower}[]`.") out.println(" * @constructor Creates a new array of the specified [size], with all elements initialized to ${defaultValue}.") out.println(" */") out.println("public class ${s}Array(size: Int) : Cloneable {") diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt index 16296338bd4..9d8270898dd 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt @@ -24,14 +24,15 @@ val MAX_PARAM_COUNT = 22 enum class FunctionKind( private val classNamePrefix: String, + val docPrefix: String?, val hasReceiverParameter: Boolean, private val superClassNamePrefix: String? ) { - FUNCTION : FunctionKind("Function", false, null) - EXTENSION_FUNCTION : FunctionKind("ExtensionFunction", true, null) - K_FUNCTION : FunctionKind("KFunction", false, "Function") - K_MEMBER_FUNCTION : FunctionKind("KMemberFunction", true, "ExtensionFunction") - K_EXTENSION_FUNCTION : FunctionKind("KExtensionFunction", true, "ExtensionFunction") + FUNCTION : FunctionKind("Function", "A function", false, null) + EXTENSION_FUNCTION : FunctionKind("ExtensionFunction", "An extension function", true, null) + K_FUNCTION : FunctionKind("KFunction", null, false, "Function") + K_MEMBER_FUNCTION : FunctionKind("KMemberFunction", null, true, "ExtensionFunction") + K_EXTENSION_FUNCTION : FunctionKind("KExtensionFunction", null, true, "ExtensionFunction") fun getFileName() = (if (isReflection()) "reflect/" else "") + classNamePrefix + "s.kt" fun getClassName(i: Int) = classNamePrefix + i @@ -62,6 +63,7 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour override fun generateBody() { for (i in 0..MAX_PARAM_COUNT) { + generateDocumentation(kind.docPrefix, i) out.print("public trait " + kind.getClassName(i)) generateTypeParameters(i, true) generateSuperClass(i) @@ -69,6 +71,12 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour } } + fun generateDocumentation(docPrefix: String?, i: Int) { + if (docPrefix == null) return + val suffix = if (i == 1) "" else "s" + out.println("/** $docPrefix that takes $i argument${suffix}. */") + } + fun generateSuperClass(i: Int) { val superClass = kind.getSuperClassName(i) if (superClass != null) { @@ -89,6 +97,12 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour } fun generateInvokeSignature(i: Int) { + if (i == 0) { + out.println(" /** Invokes the function. */") + } else { + val suffix = if (i == 1) "" else "s" + out.println(" /** Invokes the function with the specified argument${suffix}. */") + } out.print(" public fun ${if (kind.hasReceiverParameter) "T." else ""}invoke(") for (j in 1..i) { out.print("p$j: P$j") diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/iterators.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/iterators.kt index 12c8cd2773b..25a2208846f 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/iterators.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/iterators.kt @@ -24,7 +24,7 @@ class GenerateIterators(out: PrintWriter) : BuiltInsSourceGenerator(out) { override fun generateBody() { for (kind in PrimitiveType.values()) { val s = kind.capitalized - out.println("/** An iterator over a sequence of values of type $s. */") + out.println("/** An iterator over a sequence of values of type `$s`. */") out.println("public abstract class ${s}Iterator : Iterator<$s> {" ) out.println(" override final fun next() = next$s()") out.println() diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index 147fdbf35a2..1fe0bde5e76 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -21,10 +21,26 @@ import org.jetbrains.kotlin.generators.builtins.generateBuiltIns.BuiltInsSourceG import java.io.PrintWriter class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { - private val binaryOperators: List = listOf("plus", "minus", "times", "div", "mod") - private val unaryOperators: List = listOf("inc", "dec", "plus", "minus") - private val shiftOperators: List = listOf("shl", "shr", "ushr") - private val bitwiseOperators: List = listOf("and", "or", "xor") + private val binaryOperators: Map = mapOf( + "plus" to "Adds the other value to this value.", + "minus" to "Subtracts the other value from this value.", + "times" to "Multiplies this value by the other value.", + "div" to "Divides this value by the other value.", + "mod" to "Calculates the remainder of dividing this value by the other value." + ) + private val unaryOperators: Map = mapOf( + "inc" to "Increments this value.", + "dec" to "Decrements this value.", + "plus" to "Returns this value.", + "minus" to "Returns the negative of this value.") + private val shiftOperators: Map = mapOf( + "shl" to "Shifts this value left by [bits].", + "shr" to "Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit.", + "ushr" to "Shifts this value right by [bits], filling the leftmost bits with zeros.") + private val bitwiseOperators: Map = mapOf( + "and" to "Performs a bitwise AND operation between the two values.", + "or" to "Performs a bitwise OR operation between the two values.", + "xor" to "Performs a bitwise XOR operation between the two values.") private val typeDescriptions: Map = hashMapOf( PrimitiveType.DOUBLE to "double-precision 64-bit IEEE 754 floating point number", PrimitiveType.FLOAT to "single-precision 32-bit IEEE 754 floating point number", @@ -61,7 +77,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { generateBitwiseOperators(className) } - generateConversions() + generateConversions(kind) out.println("}\n") } @@ -76,6 +92,17 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { private fun generateCompareTo(thisKind: PrimitiveType) { for (otherKind in PrimitiveType.exceptBoolean) { + out.println("/**") + if (thisKind == PrimitiveType.CHAR && otherKind != PrimitiveType.CHAR) { + out.println(" * Compares the character code of this character with the specified value for order.") + } else if (thisKind != PrimitiveType.CHAR && otherKind == PrimitiveType.CHAR) { + out.println(" * Compares this value with the character code of the specified character for order.") + } else { + out.println(" * Compares this value with the specified value for order.") + } + out.println(" * Returns zero if this value is equal to the specified other value, a negative number if its less than other, ") + out.println(" * or a positive number if its greater than other.") + out.println(" */") out.print(" public ") if (otherKind == thisKind) out.print("override ") out.println("fun compareTo(other: ${otherKind.capitalized}): Int") @@ -84,17 +111,18 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { } private fun generateBinaryOperators(thisKind: PrimitiveType) { - for (name in binaryOperators) { - generateOperator(name, thisKind) + for ((name, doc) in binaryOperators) { + generateOperator(name, doc, thisKind) } } - private fun generateOperator(name: String, thisKind: PrimitiveType) { + private fun generateOperator(name: String, doc: String, thisKind: PrimitiveType) { for (otherKind in PrimitiveType.exceptBoolean) { if (thisKind == PrimitiveType.CHAR && otherKind == PrimitiveType.CHAR && name != "minus") { continue } val returnType = getOperatorReturnType(thisKind, otherKind) + out.println(" /** $doc */") out.println(" public fun $name(other: ${otherKind.capitalized}): $returnType") } out.println() @@ -102,10 +130,12 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { private fun generateRangeTo(thisKind: PrimitiveType) { if (thisKind == PrimitiveType.CHAR) { + out.println(" /** Creates a range from this value to the specified [other] value. */") out.println(" public fun rangeTo(other: Char): CharRange") } else { for (otherKind in PrimitiveType.exceptBoolean) { 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") } } @@ -114,28 +144,35 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { } private fun generateUnaryOperators(kind: PrimitiveType) { - for (name in unaryOperators) { + for ((name, doc) in unaryOperators) { 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() } private fun generateBitwiseOperators(className: String) { - for (name in shiftOperators) { + for ((name, doc) in shiftOperators) { + out.println(" /** $doc */") out.println(" public fun $name(bits: Int): $className") } - for (name in bitwiseOperators) { + for ((name, doc) in bitwiseOperators) { + out.println(" /** $doc */") out.println(" public fun $name(other: $className): $className") } + out.println(" /** Inverts the bits in this value/ */") out.println(" public fun inv(): $className") out.println() } - private fun generateConversions() { + private fun generateConversions(kind: PrimitiveType) { for (otherKind in PrimitiveType.exceptBoolean) { val name = otherKind.capitalized + if (kind == PrimitiveType.CHAR) { // Char is not a Number and does not inherit Number's javadocs + out.println(" /** Returns the value of this character as a `$name`. */") + } out.println(" public override fun to$name(): $name") } } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt index 4eae36e48df..ea91197d5e4 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt @@ -31,7 +31,10 @@ fun integerProgressionIterator(kind: ProgressionKind): String { else -> "" to "" } - return """/** An iterator over a progression of values of type $t. */ + return """/** + * An iterator over a progression of values of type `$t`. + * @property increment the number by which the value is incremented on each step. + */ class ${t}ProgressionIterator(start: $t, end: $t, val increment: $incrementType) : ${t}Iterator() { private var next = start$toInt private val finalElement: $t = getProgressionFinalElement(start$toInt, end$toInt, increment)$toType @@ -55,7 +58,10 @@ class ${t}ProgressionIterator(start: $t, end: $t, val increment: $incrementType) fun floatingPointProgressionIterator(kind: ProgressionKind): String { val t = kind.capitalized - return """/** An iterator over a progression of values of type $t. */ + return """/** + * An iterator over a progression of values of type `$t`. + * @property increment the number by which the value is incremented on each step. + */ class ${t}ProgressionIterator(start: $t, val end: $t, val increment: $t) : ${t}Iterator() { private var next = start diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt index fe0f48649a0..4d505047799 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt @@ -66,7 +66,7 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) { out.println( """/** - * A progression of values of type $t. + * A progression of values of type `$t`. */ public class $progression( override val start: $t, diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt index 31a98247649..2fcd23f3049 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt @@ -64,7 +64,7 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) { out.println( """/** - * A range of values of type $t. + * A range of values of type `$t`. */ public class $range(override val start: $t, override val end: $t) : Range<$t>, Progression<$t> { override val increment: $incrementType diff --git a/libraries/stdlib/src/generated/_DownTo.kt b/libraries/stdlib/src/generated/_DownTo.kt index 3c906017f63..77d1d4ba738 100644 --- a/libraries/stdlib/src/generated/_DownTo.kt +++ b/libraries/stdlib/src/generated/_DownTo.kt @@ -6,198 +6,443 @@ package kotlin // +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Byte): ByteProgression { return ByteProgression(this, to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Char): CharProgression { return CharProgression(this.toChar(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Short): ShortProgression { return ShortProgression(this.toShort(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Int): IntProgression { return IntProgression(this.toInt(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Long): LongProgression { return LongProgression(this.toLong(), to, -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Float): FloatProgression { return FloatProgression(this.toFloat(), to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Byte.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Byte): CharProgression { return CharProgression(this, to.toChar(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Char): CharProgression { return CharProgression(this, to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Short): ShortProgression { return ShortProgression(this.toShort(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Int): IntProgression { return IntProgression(this.toInt(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Long): LongProgression { return LongProgression(this.toLong(), to, -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Float): FloatProgression { return FloatProgression(this.toFloat(), to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Char.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Byte): ShortProgression { return ShortProgression(this, to.toShort(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Char): ShortProgression { return ShortProgression(this, to.toShort(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Short): ShortProgression { return ShortProgression(this, to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Int): IntProgression { return IntProgression(this.toInt(), to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Long): LongProgression { return LongProgression(this.toLong(), to, -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Float): FloatProgression { return FloatProgression(this.toFloat(), to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Short.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Byte): IntProgression { return IntProgression(this, to.toInt(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Char): IntProgression { return IntProgression(this, to.toInt(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Short): IntProgression { return IntProgression(this, to.toInt(), -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Int): IntProgression { return IntProgression(this, to, -1) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Long): LongProgression { return LongProgression(this.toLong(), to, -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Float): FloatProgression { return FloatProgression(this.toFloat(), to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Int.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Byte): LongProgression { return LongProgression(this, to.toLong(), -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Char): LongProgression { return LongProgression(this, to.toLong(), -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Short): LongProgression { return LongProgression(this, to.toLong(), -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Int): LongProgression { return LongProgression(this, to.toLong(), -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Long): LongProgression { return LongProgression(this, to, -1.toLong()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Float): FloatProgression { return FloatProgression(this.toFloat(), to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Long.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Byte): FloatProgression { return FloatProgression(this, to.toFloat(), -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Char): FloatProgression { return FloatProgression(this, to.toFloat(), -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Short): FloatProgression { return FloatProgression(this, to.toFloat(), -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Int): FloatProgression { return FloatProgression(this, to.toFloat(), -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Long): FloatProgression { return FloatProgression(this, to.toFloat(), -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Float): FloatProgression { return FloatProgression(this, to, -1.toFloat()) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Float.downTo(to: Double): DoubleProgression { return DoubleProgression(this.toDouble(), to, -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Byte): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Char): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Short): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Int): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Long): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Float): DoubleProgression { return DoubleProgression(this, to.toDouble(), -1.0) } +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun Double.downTo(to: Double): DoubleProgression { return DoubleProgression(this, to, -1.0) } diff --git a/libraries/stdlib/src/generated/_Elements.kt b/libraries/stdlib/src/generated/_Elements.kt index 2c5edcbeed2..003fe8b7d96 100644 --- a/libraries/stdlib/src/generated/_Elements.kt +++ b/libraries/stdlib/src/generated/_Elements.kt @@ -700,7 +700,7 @@ public fun String.first(): Char { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun Array.first(predicate: (T) -> Boolean): T { @@ -709,7 +709,7 @@ public inline fun Array.first(predicate: (T) -> Boolean): T { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean { @@ -718,7 +718,7 @@ public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte { @@ -727,7 +727,7 @@ public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun CharArray.first(predicate: (Char) -> Boolean): Char { @@ -736,7 +736,7 @@ public inline fun CharArray.first(predicate: (Char) -> Boolean): Char { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double { @@ -745,7 +745,7 @@ public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float { @@ -754,7 +754,7 @@ public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun IntArray.first(predicate: (Int) -> Boolean): Int { @@ -763,7 +763,7 @@ public inline fun IntArray.first(predicate: (Int) -> Boolean): Int { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun LongArray.first(predicate: (Long) -> Boolean): Long { @@ -772,7 +772,7 @@ public inline fun LongArray.first(predicate: (Long) -> Boolean): Long { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short { @@ -781,7 +781,7 @@ public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun Iterable.first(predicate: (T) -> Boolean): T { @@ -790,7 +790,7 @@ public inline fun Iterable.first(predicate: (T) -> Boolean): T { } /** - * "Returns the first element matching the given [predicate]. + * Returns the first element matching the given [predicate]. * @throws NoSuchElementException if no such element is found. */ public inline fun Stream.first(predicate: (T) -> Boolean): T { @@ -925,7 +925,7 @@ public fun String.firstOrNull(): Char? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun Array.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element @@ -933,7 +933,7 @@ public inline fun Array.firstOrNull(predicate: (T) -> Boolean): T? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? { for (element in this) if (predicate(element)) return element @@ -941,7 +941,7 @@ public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boo } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? { for (element in this) if (predicate(element)) return element @@ -949,7 +949,7 @@ public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? { for (element in this) if (predicate(element)) return element @@ -957,7 +957,7 @@ public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? { for (element in this) if (predicate(element)) return element @@ -965,7 +965,7 @@ public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Doubl } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? { for (element in this) if (predicate(element)) return element @@ -973,7 +973,7 @@ public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? { for (element in this) if (predicate(element)) return element @@ -981,7 +981,7 @@ public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? { for (element in this) if (predicate(element)) return element @@ -989,7 +989,7 @@ public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? { for (element in this) if (predicate(element)) return element @@ -997,7 +997,7 @@ public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element @@ -1005,7 +1005,7 @@ public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean): T? { } /** - * Returns first element matching the given [predicate], or `null` if element was not found + * Returns the first element matching the given [predicate], or `null` if element was not found */ public inline fun Stream.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element @@ -1013,7 +1013,7 @@ public inline fun Stream.firstOrNull(predicate: (T) -> Boolean): T? { } /** - * Returns first character matching the given [predicate], or `null` if character was not found + * Returns the first character matching the given [predicate], or `null` if character was not found */ public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? { for (element in this) if (predicate(element)) return element diff --git a/libraries/stdlib/src/kotlin/collections/Arrays.kt b/libraries/stdlib/src/kotlin/collections/Arrays.kt index 854e0fafce0..4da21bffa2a 100644 --- a/libraries/stdlib/src/kotlin/collections/Arrays.kt +++ b/libraries/stdlib/src/kotlin/collections/Arrays.kt @@ -1,5 +1,9 @@ package kotlin +/** + * Returns an array with the specified [size], where each element is calculated by calling the specified + * [init] function. The `init` function returns an array element given its index. + */ public inline fun Array(size: Int, init: (Int) -> T): Array { val result = arrayOfNulls(size) diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt index 912ff855c76..538aef7e98b 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt @@ -75,8 +75,12 @@ public fun ByteArray.toString(charset: String): String = String(this, charset) */ public fun ByteArray.toString(charset: Charset): String = String(this, charset) +/** + * Returns an array containing the elements of this collection. + */ [Intrinsic("kotlin.collections.copyToArray")] public fun Collection.copyToArray(): Array = throw UnsupportedOperationException() /** Returns the array if it's not null, or an empty array otherwise. */ public inline fun Array?.orEmpty(): Array = this ?: array() + diff --git a/libraries/stdlib/src/kotlin/collections/Iterators.kt b/libraries/stdlib/src/kotlin/collections/Iterators.kt index b59c9781772..4b0eb4d35d9 100644 --- a/libraries/stdlib/src/kotlin/collections/Iterators.kt +++ b/libraries/stdlib/src/kotlin/collections/Iterators.kt @@ -17,7 +17,10 @@ public fun Enumeration.iterator(): Iterator = object : Iterator { public fun Iterator.iterator(): Iterator = this /** - * Data class representing a value with an index + * Data class representing a value from a collection or sequence, along with its index in that collection or sequence. + * + * @property value the underlying value. + * @property index the index of the value in the collection or sequence. */ public data class IndexedValue(public val index: Int, public val value: T) diff --git a/libraries/stdlib/src/kotlin/collections/JUtil.kt b/libraries/stdlib/src/kotlin/collections/JUtil.kt index 5f4d861431f..d837b34f7b3 100644 --- a/libraries/stdlib/src/kotlin/collections/JUtil.kt +++ b/libraries/stdlib/src/kotlin/collections/JUtil.kt @@ -64,11 +64,14 @@ public fun hashSetOf(vararg values: T): HashSet = values.toCollection(Hash public fun linkedSetOf(vararg values: T): LinkedHashSet = values.toCollection(LinkedHashSet(values.size())) /** - * Returns an IntRange of the valid indices for this collection. + * Returns an [IntRange] of the valid indices for this collection. */ public val Collection<*>.indices: IntRange get() = 0..size() - 1 +/** + * Returns an [IntRange] that starts with zero and ends at the value of this number but does not include it. + */ public val Int.indices: IntRange get() = 0..this - 1 @@ -92,5 +95,12 @@ public fun List?.orEmpty(): List = this ?: emptyList() /** Returns this Set if it's not null and the empty set otherwise. */ public fun Set?.orEmpty(): Set = this ?: emptySet() +/** + * Returns the size of this iterable if it is known, or `null` otherwise. + */ public fun Iterable.collectionSizeOrNull(): Int? = if (this is Collection<*>) size() else null + +/** + * Returns the size of this iterable if it is known, or the specified [default] value otherwise. + */ public fun Iterable.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) size() else default \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/collections/Stream.kt b/libraries/stdlib/src/kotlin/collections/Stream.kt index cdd9c6e8bf6..3273c154ef2 100644 --- a/libraries/stdlib/src/kotlin/collections/Stream.kt +++ b/libraries/stdlib/src/kotlin/collections/Stream.kt @@ -2,12 +2,27 @@ package kotlin import java.util.* +/** + * A sequence that returns values through its iterator. The values are evaluated lazily, and the sequence + * is potentially infinite. + * + * @param T the type of elements in the sequence. + */ public trait Stream { + /** + * Returns an iterator that returns the values from the sequence. + */ public fun iterator(): Iterator } +/** + * Creates a stream that returns the specified values. + */ public fun streamOf(vararg elements: T): Stream = elements.stream() +/** + * Creates a stream that returns all values in the specified [progression]. + */ public fun streamOf(progression: Progression): Stream = object : Stream { override fun iterator(): Iterator = progression.iterator() } @@ -60,6 +75,10 @@ public class FilteringStream(private val stream: Stream, } } +/** + * A stream which returns the results of applying the given [transformer] function to the values + * in the underlying [stream]. + */ public class TransformingStream(private val stream: Stream, private val transformer: (T) -> R) : Stream { override fun iterator(): Iterator = object : Iterator { val iterator = stream.iterator() @@ -72,6 +91,11 @@ public class TransformingStream(private val stream: Stream, private val } } +/** + * A stream which returns the results of applying the given [transformer] function to the values + * in the underlying [stream], where the transformer function takes the index of the value in the underlying + * stream along with the value itself. + */ public class TransformingIndexedStream(private val stream: Stream, private val transformer: (Int, T) -> R) : Stream { override fun iterator(): Iterator = object : Iterator { val iterator = stream.iterator() @@ -103,6 +127,11 @@ public class IndexingStream(private val stream: Stream) : Stream(private val stream1: Stream, private val stream2: Stream, private val transform: (T1, T2) -> V @@ -193,6 +222,10 @@ public class Multistream(private val stream: Stream>) : Stream { } } +/** + * A stream that returns at most [count] values from the underlying [stream], and stops returning values + * as soon as that count is reached. + */ public class TakeStream(private val stream: Stream, private val count: Int ) : Stream { @@ -218,6 +251,10 @@ public class TakeStream(private val stream: Stream, } } +/** + * A stream that returns values from the underlying [stream] while the [predicate] function returns + * `true`, and stops returning values once the function returns `false` for the next element. + */ public class TakeWhileStream(private val stream: Stream, private val predicate: (T) -> Boolean ) : Stream { @@ -382,7 +419,7 @@ public class FunctionStream(private val producer: () -> T?) : Stream } /** - * Returns a stream which invokes the function to calculate the next value on each iteration until the function returns *null* + * Returns a stream which invokes the function to calculate the next value on each iteration until the function returns `null`. */ public fun stream(nextFunction: () -> T?): Stream { return FunctionStream(nextFunction) @@ -390,7 +427,7 @@ public fun stream(nextFunction: () -> T?): Stream { /** * Returns a stream which invokes the function to calculate the next value based on the previous one on each iteration - * until the function returns *null* + * until the function returns `null`. */ public /*inline*/ fun stream(initialValue: T, nextFunction: (T) -> T?): Stream = stream(nextFunction.toGenerator(initialValue)) diff --git a/libraries/stdlib/src/kotlin/concurrent/Locks.kt b/libraries/stdlib/src/kotlin/concurrent/Locks.kt index 6d3e6ccf03d..df003897bec 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Locks.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Locks.kt @@ -54,7 +54,8 @@ public inline fun ReentrantReadWriteLock.write(action: () -> T): T { } /** - * Executes the given [action] and await for CountDownLatch + * Executes the given [operation] and awaits for CountDownLatch. + * * @return the return value of the action. */ public fun Int.latch(operation: CountDownLatch.() -> T): T { diff --git a/libraries/stdlib/src/kotlin/concurrent/Thread.kt b/libraries/stdlib/src/kotlin/concurrent/Thread.kt index 8ec701f705a..238d9a9291c 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Thread.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Thread.kt @@ -2,36 +2,65 @@ package kotlin.concurrent import java.util.concurrent.* +/** + * Returns the current thread. + */ public val currentThread: Thread get() = Thread.currentThread() +/** + * Exposes the name of this thread as a property. + */ public var Thread.name: String get() = getName() set(value) { setName(value) } +/** + * Exposes the daemon flag of this thread as a property. + * The Java Virtual Machine exits when the only threads running are all daemon threads. + */ public var Thread.daemon: Boolean get() = isDaemon() set(value) { setDaemon(value) } +/** + * Exposes the alive state of this thread as a property. + */ public val Thread.alive: Boolean get() = isAlive() +/** + * Exposes the priority of this thread as a property. + */ public var Thread.priority: Int get() = getPriority() set(value) { setPriority(value) } +/** + * Exposes the context class loader of this thread as a property. + */ public var Thread.contextClassLoader: ClassLoader? get() = getContextClassLoader() set(value) { setContextClassLoader(value) } +/** + * Creates a thread that runs the specified [block] of code.\ + * + * @param start if `true`, the thread is immediately started. + * @param daemon if `true`, the thread is created as a daemon thread. The Java Virtual Machine exits when + * the only threads running are all daemon threads. + * @param contextClassLoader the class loader to use for loading classes and resources in this thread. + * @param name the name of the thread. + * @param priority the priority of the thread. + */ public fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: () -> Unit): Thread { val thread = object : Thread() { public override fun run() { @@ -53,15 +82,15 @@ public fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLo /** * Allows you to use the executor as a function to - * execute the given block on the [[Executor]]. + * execute the given block on the [Executor]. */ public fun Executor.invoke(action: () -> Unit) { execute(action) } /** - * Allows you to use the executor as a function to - * execute the given block on the [[Executor]]. + * Allows you to use the executor service as a function to + * execute the given block on the [ExecutorService]. */ public fun ExecutorService.invoke(action: () -> T): Future { return submit(action) diff --git a/libraries/stdlib/src/kotlin/concurrent/Timer.kt b/libraries/stdlib/src/kotlin/concurrent/Timer.kt index d2244c21149..a2a71ec5d89 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Timer.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Timer.kt @@ -4,66 +4,123 @@ import java.util.Timer import java.util.TimerTask import java.util.Date +/** + * Schedules an [action] to be executed after the specified [delay] (expressed in milliseconds). + */ public fun Timer.schedule(delay: Long, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) schedule(task, delay) return task } +/** + * Schedules an [action] to be executed at the specified [time]. + */ public fun Timer.schedule(time: Date, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) schedule(task, time) return task } +/** + * Schedules an [action] to be executed periodically, starting after the specified [delay] (expressed + * in milliseconds) and with the interval of [period] milliseconds between the end of the previous task + * and the start of the next one. + */ public fun Timer.schedule(delay: Long, period: Long, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) schedule(task, delay, period) return task } +/** + * Schedules an [action] to be executed periodically, starting at the specified [time] and with the + * interval of [period] milliseconds between the end of the previous task and the start of the next one. + */ public fun Timer.schedule(time: Date, period: Long, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) schedule(task, time, period) return task } +/** + * Schedules an [action] to be executed periodically, starting after the specified [delay] (expressed + * in milliseconds) and with the interval of [period] milliseconds between the start of the previous task + * and the start of the next one. + */ public fun Timer.scheduleAtFixedRate(delay: Long, period: Long, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) scheduleAtFixedRate(task, delay, period) return task } +/** + * Schedules an [action] to be executed periodically, starting at the specified [time] and with the + * interval of [period] milliseconds between the start of the previous task and the start of the next one. + */ public fun Timer.scheduleAtFixedRate(time: Date, period: Long, action: TimerTask.() -> Unit): TimerTask { val task = timerTask(action) scheduleAtFixedRate(task, time, period) return task } +/** + * Creates a timer that executes the specified [action] periodically, starting after the specified [initialDelay] + * (expressed in milliseconds) and with the interval of [period] milliseconds between the end of the previous task + * and the start of the next one. + * + * @param name the name to use for the thread which is running the timer. + * @param daemon if true, the thread is started as a daemon thread (the VM will exit when only daemon threads are running) + */ public fun timer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, action: TimerTask.() -> Unit): Timer { val timer = if (name == null) Timer(daemon) else Timer(name, daemon) timer.schedule(initialDelay, period, action) return timer } +/** + * Creates a timer that executes the specified [action] periodically, starting at the specified [startAt] date + * and with the interval of [period] milliseconds between the end of the previous task and the start of the next one. + * + * @param name the name to use for the thread which is running the timer. + * @param daemon if true, the thread is started as a daemon thread (the VM will exit when only daemon threads are running) + */ public fun timer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, action: TimerTask.() -> Unit): Timer { val timer = if (name == null) Timer(daemon) else Timer(name, daemon) timer.schedule(startAt, period, action) return timer } +/** + * Creates a timer that executes the specified [action] periodically, starting after the specified [initialDelay] + * (expressed in milliseconds) and with the interval of [period] milliseconds between the start of the previous task + * and the start of the next one. + * + * @param name the name to use for the thread which is running the timer. + * @param daemon if true, the thread is started as a daemon thread (the VM will exit when only daemon threads are running) + */ public fun fixedRateTimer(name: String? = null, daemon: Boolean = false, initialDelay: Long = 0.toLong(), period: Long, action: TimerTask.() -> Unit): Timer { val timer = if (name == null) Timer(daemon) else Timer(name, daemon) timer.scheduleAtFixedRate(initialDelay, period, action) return timer } +/** + * Creates a timer that executes the specified [action] periodically, starting at the specified [startAt] date + * and with the interval of [period] milliseconds between the start of the previous task and the start of the next one. + * + * @param name the name to use for the thread which is running the timer. + * @param daemon if true, the thread is started as a daemon thread (the VM will exit when only daemon threads are running) + */ public fun fixedRateTimer(name: String? = null, daemon: Boolean = false, startAt: Date, period: Long, action: TimerTask.() -> Unit): Timer { val timer = if (name == null) Timer(daemon) else Timer(name, daemon) timer.scheduleAtFixedRate(startAt, period, action) return timer } +/** + * Wraps the specified [action] in a `TimerTask`. + */ public fun timerTask(action: TimerTask.() -> Unit): TimerTask = object : TimerTask() { public override fun run() { action() diff --git a/libraries/stdlib/src/kotlin/io/Console.kt b/libraries/stdlib/src/kotlin/io/Console.kt index 8568c60edd8..35f49022422 100644 --- a/libraries/stdlib/src/kotlin/io/Console.kt +++ b/libraries/stdlib/src/kotlin/io/Console.kt @@ -9,88 +9,88 @@ import java.io.BufferedReader */ public val defaultBufferSize: Int = 64 * 1024 -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Any?) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Int) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Long) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Byte) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Short) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Char) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Boolean) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Float) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: Double) { System.out.print(message) } -/** Prints the given message to [System.out] */ +/** Prints the given message to the standard output stream. */ public fun print(message: CharArray) { System.out.print(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Any?) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Int) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Long) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Byte) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Short) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Char) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Boolean) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Float) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: Double) { System.out.println(message) } -/** Prints the given message and newline to [System.out] */ +/** Prints the given message and newline to the standard output stream. */ public fun println(message: CharArray) { System.out.println(message) } -/** Prints a newline to [System.out] */ +/** Prints a newline to the standard output stream. */ public fun println() { System.out.println() } @@ -137,7 +137,8 @@ private val stdin: BufferedReader = BufferedReader(InputStreamReader(object : In })) /** - * Reads a line of input from [System.in] + * Reads a line of input from the standard input stream. + * * @return the line read or null if the input stream is redirected to a file and the end of file has been reached. */ public fun readLine(): String? = stdin.readLine() diff --git a/libraries/stdlib/src/kotlin/jvm/BuiltinExtensions.kt b/libraries/stdlib/src/kotlin/jvm/BuiltinExtensions.kt index b1ea87b283c..a73f40eec4e 100644 --- a/libraries/stdlib/src/kotlin/jvm/BuiltinExtensions.kt +++ b/libraries/stdlib/src/kotlin/jvm/BuiltinExtensions.kt @@ -15,20 +15,56 @@ */ package kotlin.jvm +/** + * A constant holding the minimum value an `Int` can have, -2^31. + */ public val Int.Default.MIN_VALUE: Int get() = java.lang.Integer.MIN_VALUE +/** + * A constant holding the maximum value an `Int` can have, 2^31-1. + */ public val Int.Default.MAX_VALUE: Int get() = java.lang.Integer.MAX_VALUE +/** + * A constant holding the smallest positive nonzero value of type `Double`, 2^-1074. + */ public val Double.Default.MIN_VALUE: Double get() = java.lang.Double.MIN_VALUE +/** + * A constant holding the largest positive finite value of type `Double`, (2-2^-52)*2^1023. + */ public val Double.Default.MAX_VALUE: Double get() = java.lang.Double.MAX_VALUE +/** + * A constant holding the smallest positive nonzero value of type `Float`, 2^-149. + */ public val Float.Default.MIN_VALUE: Float get() = java.lang.Float.MIN_VALUE +/** + * * A constant holding the largest positive finite value of type `Float`, (2-2^-23)*2^127. + */ public val Float.Default.MAX_VALUE: Float get() = java.lang.Float.MAX_VALUE +/** + * A constant holding the minimum value a `Long` can have, -2^63. + */ public val Long.Default.MIN_VALUE: Long get() = java.lang.Long.MIN_VALUE +/** + * A constant holding the maximum value a `Long` can have, 2^63-1. + */ public val Long.Default.MAX_VALUE: Long get() = java.lang.Long.MAX_VALUE +/** + * A constant holding the minimum value a `Short` can have, -2^15. + */ public val Short.Default.MIN_VALUE: Short get() = java.lang.Short.MIN_VALUE +/** + * A constant holding the maximum value a `Short` can have, 2^15-1. + */ public val Short.Default.MAX_VALUE: Short get() = java.lang.Short.MAX_VALUE +/** + * A constant holding the minimum value a `Byte` can have, -128. + */ public val Byte.Default.MIN_VALUE: Byte get() = java.lang.Byte.MIN_VALUE +/** + * A constant holding the maximum value a `Byte` can have, 127. + */ public val Byte.Default.MAX_VALUE: Byte get() = java.lang.Byte.MAX_VALUE \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/platform/annotations.kt b/libraries/stdlib/src/kotlin/platform/annotations.kt index 3c5f7cc61de..ed17ed8e4e4 100644 --- a/libraries/stdlib/src/kotlin/platform/annotations.kt +++ b/libraries/stdlib/src/kotlin/platform/annotations.kt @@ -21,6 +21,7 @@ package kotlin.platform * which is generated from this element. * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/java-interop.html#handling-signature-clashes-with-platformname) * for more information. + * @property name the name of the element. */ public annotation class platformName(public val name: String) diff --git a/libraries/stdlib/src/kotlin/test/Test.kt b/libraries/stdlib/src/kotlin/test/Test.kt index 71033424921..2807497b414 100644 --- a/libraries/stdlib/src/kotlin/test/Test.kt +++ b/libraries/stdlib/src/kotlin/test/Test.kt @@ -89,18 +89,49 @@ public fun fails(block: () -> Unit): Throwable? { } /** - * A plugin for performing assertions which can reuse JUnit or TestNG + * Abstracts the logic for performing assertions. Specific implementations of [Asserter] can use JUnit + * or TestNG assertion facilities. */ public trait Asserter { + /** + * Asserts that the specified value is true. + * + * @param message the message to report if the assertion fails. + */ public fun assertTrue(message: String, actual: Boolean): Unit + /** + * Asserts that the specified values are equal. + * + * @param message the message to report if the assertion fails. + */ public fun assertEquals(message: String, expected: Any?, actual: Any?): Unit + /** + * Asserts that the specified values are not equal. + * + * @param message the message to report if the assertion fails. + */ public fun assertNotEquals(message: String, illegal: Any?, actual: Any?): Unit + /** + * Asserts that the specified value is not null. + * + * @param message the message to report if the assertion fails. + */ public fun assertNotNull(message: String, actual: Any?): Unit + /** + * Asserts that the specified value is null. + * + * @param message the message to report if the assertion fails. + */ public fun assertNull(message: String, actual: Any?): Unit + /** + * Fails the current test with the specified message. + * + * @param message the message to report. + */ public fun fail(message: String): Unit } diff --git a/libraries/stdlib/src/kotlin/test/TestJVM.kt b/libraries/stdlib/src/kotlin/test/TestJVM.kt index 9326b5aa208..c9209e66407 100644 --- a/libraries/stdlib/src/kotlin/test/TestJVM.kt +++ b/libraries/stdlib/src/kotlin/test/TestJVM.kt @@ -26,6 +26,10 @@ public inline fun todo(block: ()-> Any) { private var _asserter: Asserter? = null +/** + * The active implementation of [Asserter]. An implementation of [Asserter] can be provided + * using the [Java service loader](http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html) mechanism. + */ public var asserter: Asserter get() { if (_asserter == null) { @@ -51,7 +55,7 @@ public var asserter: Asserter /** - * Default implementation to avoid dependency on JUnit or TestNG + * Default [Asserter] implementation to avoid dependency on JUnit or TestNG. */ private class DefaultAsserter() : Asserter { diff --git a/libraries/stdlib/src/kotlin/text/CharJVM.kt b/libraries/stdlib/src/kotlin/text/CharJVM.kt index f43160249b5..1c92652b348 100644 --- a/libraries/stdlib/src/kotlin/text/CharJVM.kt +++ b/libraries/stdlib/src/kotlin/text/CharJVM.kt @@ -16,37 +16,59 @@ package kotlin +/** + * Returns `true` if this character (Unicode code point) is defined in Unicode. + */ public fun Char.isDefined(): Boolean = Character.isDefined(this) +/** + * Returns `true` if this character (Unicode code point) is a digit. + */ public fun Char.isDigit(): Boolean = Character.isDigit(this) +/** + * Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). + */ public fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) +/** + * Returns `true` if this character (Unicode code point) should be regarded as an ignorable + * character in a Java identifier or a Unicode identifier. + */ public fun Char.isIdentifierIgnorable(): Boolean = Character.isIdentifierIgnorable(this) +/** + * Returns `true` if this character is an ISO control character. + */ public fun Char.isISOControl(): Boolean = Character.isISOControl(this) +/** + * Returns `true` if this character (Unicode code point) may be part of a Java identifier as other than the first character. + */ public fun Char.isJavaIdentifierPart(): Boolean = Character.isJavaIdentifierPart(this) +/** + * Returns `true` if this character is permissible as the first character in a Java identifier. + */ public fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdentifierStart(this) +deprecated("Please use Char.isJavaIdentifierStart() instead") public fun Char.isJavaLetter(): Boolean = Character.isJavaLetter(this) +deprecated("Please use Char.isJavaIdentifierPart() instead") public fun Char.isJavaLetterOrDigit(): Boolean = Character.isJavaLetterOrDigit(this) /** - * Returns true if the character is whitespace - * - * @includeFunctionBody ../../test/text/StringTest.kt count + * Returns `true` if the character is whitespace. */ public fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) /** - * Returns true if this character is upper case + * Returns `true` if this character is upper case. */ public fun Char.isUpperCase(): Boolean = Character.isUpperCase(this) /** - * Returns true if this character is lower case + * Returns `true` if this character is lower case. */ public fun Char.isLowerCase(): Boolean = Character.isLowerCase(this) diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index bdcce158494..824b5424298 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -7,127 +7,363 @@ import java.util.regex.MatchResult import java.util.regex.Pattern import java.nio.charset.Charset +/** + * Returns the index within this string of the last occurrence of the specified substring. + */ public fun String.lastIndexOf(str: String): Int = (this as java.lang.String).lastIndexOf(str) +/** + * Returns the index within this string of the last occurrence of the specified character. + */ public fun String.lastIndexOf(ch: Char): Int = (this as java.lang.String).lastIndexOf(ch.toString()) +/** + * Compares this string to another string, ignoring case considerations. + */ public fun String.equalsIgnoreCase(anotherString: String): Boolean = (this as java.lang.String).equalsIgnoreCase(anotherString) +/** + * Returns the hash code of this string. + */ public fun String.hashCode(): Int = (this as java.lang.String).hashCode() +/** + * Returns the index within this string of the first occurrence of the specified substring. + */ public fun String.indexOf(str: String): Int = (this as java.lang.String).indexOf(str) +/** + * Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset. + */ public fun String.indexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex) +/** + * Returns a copy of this string with all occurrences of [oldChar] replaced with [newChar]. + */ public fun String.replace(oldChar: Char, newChar: Char): String = (this as java.lang.String).replace(oldChar, newChar) +/** + * Returns a new string obtained by replacing each substring of this string that matches the given regular expression + * with the given [replacement]. + */ public fun String.replaceAll(regex: String, replacement: String): String = (this as java.lang.String).replaceAll(regex, replacement) +/** + * Returns a copy of this string with leading and trailing whitespace trimmed. + */ public fun String.trim(): String = (this as java.lang.String).trim() +/** + * Returns a copy of this string converted to upper case using the rules of the default locale. + */ public fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase() +/** + * Returns a copy of this string converted to lower case using the rules of the default locale. + */ public fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() +/** + * Returns a new character array containing the characters from this string. + */ public fun String.toCharArray(): CharArray = (this as java.lang.String).toCharArray() +/** + * Uses this string as a format string and returns a string obtained by substituting the specified arguments, + * using the default locale. + */ public fun String.format(vararg args: Any?): String = java.lang.String.format(this, *args) +/** + * Uses this string as a format string and returns a string obtained by substituting the specified arguments, using + * the specified locale. + */ public fun String.format(locale: Locale, vararg args : Any?) : String = java.lang.String.format(locale, this, *args) +/** + * Splits this string around matches of the given regular expression. + */ public fun String.split(regex: String): Array = (this as java.lang.String).split(regex) +/** + * Splits this string around occurrences of the specified character. + */ public fun String.split(ch: Char): Array = (this as java.lang.String).split(java.util.regex.Pattern.quote(ch.toString())) +/** + * Returns a substring of this string starting with the specified index. + */ public fun String.substring(beginIndex: Int): String = (this as java.lang.String).substring(beginIndex) +/** + * Returns the substring of this string starting and ending at the specified indices. + */ public fun String.substring(beginIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(beginIndex, endIndex) +/** + * Returns `true` if this string starts with the specified prefix. + */ public fun String.startsWith(prefix: String): Boolean = (this as java.lang.String).startsWith(prefix) +/** + * Returns `true` if a subsring of this string starting at the specified offset starts with the specified prefix. + */ public fun String.startsWith(prefix: String, toffset: Int): Boolean = (this as java.lang.String).startsWith(prefix, toffset) +/** + * Returns `true` if this string starts with the specified character. + */ public fun String.startsWith(ch: Char): Boolean = (this as java.lang.String).startsWith(ch.toString()) +/** + * Returns `true` if this string contains the specified sequence of characters as a substring. + */ public fun String.contains(seq: CharSequence): Boolean = (this as java.lang.String).contains(seq) +/** + * Returns `true` if this string ends with the specified suffix. + */ public fun String.endsWith(suffix: String): Boolean = (this as java.lang.String).endsWith(suffix) +/** + * Returns `true` if this string ends with the specified character. + */ public fun String.endsWith(ch: Char): Boolean = (this as java.lang.String).endsWith(ch.toString()) // "constructors" for String +/** + * Converts the data from a portion of the specified array of bytes to characters using the specified character set + * and returns the conversion result as a string. + * + * @param bytes the source array for the conversion. + * @param offset the offset in the array of the data to be converted. + * @param length the number of bytes to be converted. + * @param charsetName the name of the character set to use. + */ public fun String(bytes: ByteArray, offset: Int, length: Int, charsetName: String): String = java.lang.String(bytes, offset, length, charsetName) as String +/** + * Converts the data from a portion of the specified array of bytes to characters using the specified character set + * and returns the conversion result as a string. + * + * @param bytes the source array for the conversion. + * @param offset the offset in the array of the data to be converted. + * @param length the number of bytes to be converted. + * @param charset the character set to use. + */ public fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String = java.lang.String(bytes, offset, length, charset) as String +/** + * Converts the data from the specified array of bytes to characters using the specified character set + * and returns the conversion result as a string. + */ public fun String(bytes: ByteArray, charsetName: String): String = java.lang.String(bytes, charsetName) as String +/** + * Converts the data from the specified array of bytes to characters using the specified character set + * and returns the conversion result as a string. + */ public fun String(bytes: ByteArray, charset: Charset): String = java.lang.String(bytes, charset) as String -public fun String(bytes: ByteArray, i: Int, i1: Int): String = java.lang.String(bytes, i, i1, Charsets.UTF_8) as String +/** + * Converts the data from a portion of the specified array of bytes to characters using the UTF-8 character set + * and returns the conversion result as a string. + * + * @param bytes the source array for the conversion. + * @param offset the offset in the array of the data to be converted. + * @param length the number of bytes to be converted. + */ +public fun String(bytes: ByteArray, offset: Int, length: Int): String = java.lang.String(bytes, offset, length, Charsets.UTF_8) as String +/** + * Converts the data from the specified array of bytes to characters using the UTF-8 character set + * and returns the conversion result as a string. + */ public fun String(bytes: ByteArray): String = java.lang.String(bytes, Charsets.UTF_8) as String +/** + * Converts the characters in the specified array to a string. + */ public fun String(chars: CharArray): String = java.lang.String(chars) as String +/** + * Converts the contents of the specified StringBuffer to a string. + */ public fun String(stringBuffer: java.lang.StringBuffer): String = java.lang.String(stringBuffer) as String +/** + * Converts the contents of the specified StringBuilder to a string. + */ public fun String(stringBuilder: java.lang.StringBuilder): String = java.lang.String(stringBuilder) as String +/** + * Replaces the first substring of this string that matches the given regular expression with the given replacement. + */ public fun String.replaceFirst(regex: String, replacement: String): String = (this as java.lang.String).replaceFirst(regex, replacement) +/** + * Splits this string into at most [limit] chunks around matches of the given regular expression. + */ public fun String.split(regex: String, limit: Int): Array = (this as java.lang.String).split(regex, limit) +/** + * Returns the character (Unicode code point) at the specified index. + */ public fun String.codePointAt(index: Int): Int = (this as java.lang.String).codePointAt(index) +/** + * Returns the character (Unicode code point) before the specified index. + */ public fun String.codePointBefore(index: Int): Int = (this as java.lang.String).codePointBefore(index) +/** + * Returns the number of Unicode code points in the specified text range of this String. + */ public fun String.codePointCount(beginIndex: Int, endIndex: Int): Int = (this as java.lang.String).codePointCount(beginIndex, endIndex) +/** + * Compares two strings lexicographically, ignoring case differences. + */ public fun String.compareToIgnoreCase(str: String): Int = (this as java.lang.String).compareToIgnoreCase(str) +/** + * Returns a new string obtained by concatenating this string and the specified string. + */ public fun String.concat(str: String): String = (this as java.lang.String).concat(str) +/** + * Returns `true` if this string is equal to the contents of the specified CharSequence. + */ public fun String.contentEquals(cs: CharSequence): Boolean = (this as java.lang.String).contentEquals(cs) +/** + * Returns `true` if this string is equal to the contents of the specified StringBuffer. + */ public fun String.contentEquals(sb: StringBuffer): Boolean = (this as java.lang.String).contentEquals(sb) +/** + * Copies the characters from a substring of this string into the specified character array. + * @param srcBegin the start offset (inclusive) of the substring to copy. + * @param srcEnd the end offset (exclusive) of the substring to copy. + * @param dst the array to copy to. + * @param dstBegin the position in the array to copy to. + */ public fun String.getChars(srcBegin: Int, srcEnd: Int, dst: CharArray, dstBegin: Int): Unit = (this as java.lang.String).getChars(srcBegin, srcEnd, dst, dstBegin) +/** + * Returns the index within this string of the first occurrence of the specified character. + */ public fun String.indexOf(ch: Char): Int = (this as java.lang.String).indexOf(ch.toString()) +/** + * Returns the index within this string of the first occurrence of the specified character, starting from the specified offset. + */ public fun String.indexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toString(), fromIndex) +/** + * Returns a canonical representation for this string object. + */ public fun String.intern(): String = (this as java.lang.String).intern() +/** + * Returns `true` if this string is empty (contains no characters). + */ public fun String.isEmpty(): Boolean = (this as java.lang.String).isEmpty() +/** + * Returns the index within this string of the last occurrence of the specified character. + */ public fun String.lastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toString(), fromIndex) +/** + * Returns the index within this string of the last occurrence of the specified character, starting from the specified offset. + */ public fun String.lastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex) +/** + * Returns `true` if this string matches the given regular expression. + */ public fun String.matches(regex: String): Boolean = (this as java.lang.String).matches(regex) +/** + * Returns the index within this string that is offset from the given [index] by [codePointOffset] code points. + */ public fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int = (this as java.lang.String).offsetByCodePoints(index, codePointOffset) +/** + * Returns `true` if the specified range in this string is equal to the specified range in another string. + * @param ignoreCase if `true`, character case is ignored when comparing. + * @param toffset the start offset in this string of the substring to compare. + * @param other the string against a substring of which the comparison is performed. + * @param ooffset the start offset in the other string of the substring to compare. + * @param len the length of the substring to compare. + */ public fun String.regionMatches(ignoreCase: Boolean, toffset: Int, other: String, ooffset: Int, len: Int): Boolean = (this as java.lang.String).regionMatches(ignoreCase, toffset, other, ooffset, len) +/** + * Returns `true` if the specified range in this string is equal to the specified range in another string. + * @param toffset the start offset in this string of the substring to compare. + * @param other the string against a substring of which the comparison is performed. + * @param ooffset the start offset in the other string of the substring to compare. + * @param len the length of the substring to compare. + */ public fun String.regionMatches(toffset: Int, other: String, ooffset: Int, len: Int): Boolean = (this as java.lang.String).regionMatches(toffset, other, ooffset, len) +/** + * Returns a new string obtained by replacing all occurrences of the [target] substring in this string + * with the specified [replacement] string. + */ public fun String.replace(target: CharSequence, replacement: CharSequence): String = (this as java.lang.String).replace(target, replacement) +/** + * Returns a copy of this string converted to lower case using the rules of the specified locale. + */ public fun String.toLowerCase(locale: java.util.Locale): String = (this as java.lang.String).toLowerCase(locale) +/** + * Returns a copy of this string converted to upper case using the rules of the specified locale. + */ public fun String.toUpperCase(locale: java.util.Locale): String = (this as java.lang.String).toUpperCase(locale) +/** + * Returns `true` if the contents of this string is equal to the word "true", ignoring case, and `false` otherwise. + */ public fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this) + +/** + * Parses the string as a [Short] number and returns the result. + * @throws NumberFormatException if the string is not a valid representation of a number. + */ public fun String.toShort(): Short = java.lang.Short.parseShort(this) + +/** + * Parses the string as an [Int] number and returns the result. + * @throws NumberFormatException if the string is not a valid representation of a number. + */ public fun String.toInt(): Int = java.lang.Integer.parseInt(this) + +/** + * Parses the string as a [Long] number and returns the result. + * @throws NumberFormatException if the string is not a valid representation of a number. + */ public fun String.toLong(): Long = java.lang.Long.parseLong(this) + +/** + * Parses the string as a [Float] number and returns the result. + * @throws NumberFormatException if the string is not a valid representation of a number. + */ public fun String.toFloat(): Float = java.lang.Float.parseFloat(this) + +/** + * Parses the string as a [Double] number and returns the result. + * @throws NumberFormatException if the string is not a valid representation of a number. + */ public fun String.toDouble(): Double = java.lang.Double.parseDouble(this) +/** + * Returns the list of all characters in this string. + */ public fun String.toCharList(): List = toCharArray().toList() /** @@ -138,7 +374,14 @@ public fun String.toCharList(): List = toCharArray().toList() */ public 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. + */ public fun String.toByteArray(charset: String): ByteArray = (this as java.lang.String).getBytes(charset) + +/** + * Encodes the contents of this string using the specified character set and returns the resulting byte array. + */ public fun String.toByteArray(charset: Charset = Charsets.UTF_8): ByteArray = (this as java.lang.String).getBytes(charset) deprecated("Use toByteArray() instead to emphasize copy behaviour") @@ -151,7 +394,7 @@ deprecated("Use toByteArray(charset) instead to emphasize copy behaviour") public fun String.getBytes(charset: String): ByteArray = (this as java.lang.String).getBytes(charset) /** - * Returns a subsequence specified by given [range]. + * Returns a subsequence of this sequence specified by given [range]. */ public fun CharSequence.slice(range: IntRange): CharSequence { return subSequence(range.start, range.end + 1) // inclusive diff --git a/libraries/stdlib/src/kotlin/text/Typography.kt b/libraries/stdlib/src/kotlin/text/Typography.kt index 93f7d36c0c4..b7b532326c5 100644 --- a/libraries/stdlib/src/kotlin/text/Typography.kt +++ b/libraries/stdlib/src/kotlin/text/Typography.kt @@ -4,42 +4,80 @@ package kotlin * Defines names for Unicode symbols used in proper Typography */ public object Typography { + /** The character " */ public val quote: Char = '\u0022' + /** The character & */ public val amp: Char = '\u0026' + /** The character < */ public val less: Char = '\u003C' + /** The character > */ public val greater: Char = '\u003E' + /** The non-breaking space character */ public val nbsp: Char = '\u00A0' + /** The character × */ public val times: Char = '\u00D7' + /** The character ¢ */ public val cent: Char = '\u00A2' + /** The character £ */ public val pound: Char = '\u00A3' + /** The character § */ public val section: Char = '\u00A7' + /** The character © */ public val copyright: Char = '\u00A9' + /** The character « */ public val leftGuillemete: Char = '\u00AB' + /** The character » */ public val rightGuillemete: Char = '\u00BB' + /** The character ® */ public val registered: Char = '\u00AE' + /** The character ° */ public val degree: Char = '\u00B0' + /** The character ± */ public val plusMinus: Char = '\u00B1' + /** The character ¶ */ public val paragraph: Char = '\u00B6' + /** The character · */ public val middleDot: Char = '\u00B7' + /** The character ½ */ public val half: Char = '\u00BD' + /** The character – */ public val ndash: Char = '\u2013' + /** The character — */ public val mdash: Char = '\u2014' + /** The character ‘ */ public val leftSingleQuote: Char = '\u2018' + /** The character ’ */ public val rightSingleQuote: Char = '\u2019' + /** The character ‚ */ public val lowSingleQuote: Char = '\u201A' + /** The character “ */ public val leftDoubleQuote: Char = '\u201C' + /** The character ” */ public val rightDoubleQuote: Char = '\u201D' - public val lowDoubleQuote: Char = '\u201D' + /** The character „ */ + public val lowDoubleQuote: Char = '\u201E' + /** The character † */ public val dagger: Char = '\u2020' + /** The character ‡ */ public val doubleDagger: Char = '\u2021' + /** The character • */ public val bullet: Char = '\u2022' + /** The character … */ public val ellipsis: Char = '\u2026' + /** The character ′ */ public val prime: Char = '\u2032' + /** The character ″ */ public val doublePrime: Char = '\u2033' + /** The character € */ public val euro: Char = '\u20AC' + /** The character ™ */ public val tm: Char = '\u2122' + /** The character ≈ */ public val almostEqual: Char = '\u2248' + /** The character ≠ */ public val notEqual: Char = '\u2260' + /** The character ≤ */ public val lessOrEqual: Char = '\u2264' + /** The character ≥ */ public val greaterOrEqual: Char = '\u2265' } \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/util/Functions.kt b/libraries/stdlib/src/kotlin/util/Functions.kt index 84dd0e299b7..fb5f0a95822 100644 --- a/libraries/stdlib/src/kotlin/util/Functions.kt +++ b/libraries/stdlib/src/kotlin/util/Functions.kt @@ -1,5 +1,10 @@ package kotlin +/** + * Converts a function that takes one argument and returns a value of the same type to a generator function. + * The generator function calls this function, passing to it either [initialValue] on the first iteration + * or the previously returned value on subsequent iterations, and returns the returned value. + */ public fun Function1.toGenerator(initialValue: T): Function0 { var nextValue: T? = initialValue return { diff --git a/libraries/stdlib/src/kotlin/util/JLangJVM.kt b/libraries/stdlib/src/kotlin/util/JLangJVM.kt index cffea84c401..9ef9af19db3 100644 --- a/libraries/stdlib/src/kotlin/util/JLangJVM.kt +++ b/libraries/stdlib/src/kotlin/util/JLangJVM.kt @@ -6,7 +6,7 @@ import kotlin.jvm.internal.unsafe.* import kotlin.jvm.internal.Intrinsic /** - * This annotation indicates what exceptions should be declared by a function when compiled to a JVM method + * This annotation indicates what exceptions should be declared by a function when compiled to a JVM method. * * Example: * @@ -20,6 +20,8 @@ import kotlin.jvm.internal.Intrinsic * ``` * String readFile(String name) throws IOException {...} * ``` + * + * @property exceptionClasses the list of checked exception classes that may be thrown by the function. */ Retention(RetentionPolicy.SOURCE) public annotation class throws(public vararg val exceptionClasses: Class) @@ -48,5 +50,8 @@ public inline fun synchronized(lock: Any, block: () -> R): R { } } +/** + * Returns the annotation type of this annotation. + */ public fun T.annotationType() : Class = (this as java.lang.annotation.Annotation).annotationType() as Class diff --git a/libraries/stdlib/src/kotlin/util/Tuples.kt b/libraries/stdlib/src/kotlin/util/Tuples.kt index 1960bbd2ec9..6ce04fcfbca 100644 --- a/libraries/stdlib/src/kotlin/util/Tuples.kt +++ b/libraries/stdlib/src/kotlin/util/Tuples.kt @@ -13,8 +13,8 @@ import java.io.Serializable * * @param A type of the first value * @param B type of the second value - * @param first First value - * @param second Second value + * @property first First value + * @property second Second value * @constructor Creates a new instance of Pair. */ public data class Pair( @@ -29,7 +29,7 @@ public data class Pair( } /** - * Converts a pair into a list. + * Converts this pair into a list. */ public fun Pair.toList(): List = listOf(first, second) @@ -44,9 +44,9 @@ public fun Pair.toList(): List = listOf(first, second) * @param A type of the first value * @param B type of the second value * @param C type of the third value - * @param first First value - * @param second Second value - * @param third Third value + * @property first First value + * @property second Second value + * @property third Third value */ public data class Triple( public val first: A, @@ -61,6 +61,6 @@ public data class Triple( } /** - * Converts triple into a list + * Converts this triple into a list. */ public fun Triple.toList(): List = listOf(first, second, third) diff --git a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateDownTos.kt b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateDownTos.kt index 7a0f50dd611..63665d3226c 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateDownTos.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateDownTos.kt @@ -32,6 +32,11 @@ private fun generateDownTos(outputFile: File, header: String) { } writer.println(""" +/** + * Returns a progression from this value down to the specified [to] value. + * + * The [to] value has to be less than this value. + */ public fun $fromType.downTo(to: $toType): $progressionType { return $progressionType($fromExpr, $toExpr, $incrementExpr) }""") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 21b8954d99a..0b8a5d2254c 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -277,7 +277,7 @@ fun elements(): List { templates add f("first(predicate: (T) -> Boolean)") { inline(true) - doc { """"Returns the first element matching the given [predicate]. + doc { """Returns the first element matching the given [predicate]. @throws NoSuchElementException if no such element is found.""" } doc(Strings) { """Returns the first character matching the given [predicate]. @throws NoSuchElementException if no such character is found.""" } @@ -293,8 +293,8 @@ fun elements(): List { templates add f("firstOrNull(predicate: (T) -> Boolean)") { inline(true) - doc { "Returns first element matching the given [predicate], or `null` if element was not found" } - doc(Strings) { "Returns first character matching the given [predicate], or `null` if character was not found" } + doc { "Returns the first element matching the given [predicate], or `null` if element was not found" } + doc(Strings) { "Returns the first character matching the given [predicate], or `null` if character was not found" } returns("T?") body { """