Add SinceKotlin to new coerceIn method.

This commit is contained in:
Ilya Gorbunov
2016-12-19 17:53:47 +03:00
parent 10f8e70322
commit 2209631f1a
4 changed files with 4 additions and 0 deletions
@@ -868,6 +868,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
return when {
@@ -620,6 +620,7 @@ public header fun Double.coerceIn(minimumValue: Double, maximumValue: Double): D
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
@SinceKotlin("1.1")
public header fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T
/**
@@ -869,6 +869,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
return when {
@@ -90,6 +90,7 @@ fun comparables(): List<GenericFunction> {
templates add f("coerceIn(range: ClosedFloatingPointRange<T>)") {
sourceFile(SourceFile.Ranges)
only(Generic)
since("1.1")
returns("SELF")
typeParam("T: Comparable<T>")
doc {