diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index 2271752701d..a784b639693 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -13,35 +13,40 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Checks if the specified [item] belongs to this range. */ -public fun IntRange.contains(item: Byte): Boolean { +platformName("intRangeContains") +public fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun LongRange.contains(item: Byte): Boolean { +platformName("longRangeContains") +public fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ShortRange.contains(item: Byte): Boolean { +platformName("shortRangeContains") +public fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun DoubleRange.contains(item: Byte): Boolean { +platformName("doubleRangeContains") +public fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun FloatRange.contains(item: Byte): Boolean { +platformName("floatRangeContains") +public fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -83,35 +88,40 @@ public fun FloatRange.contains(item: Char): Nothing { /** * Checks if the specified [item] belongs to this range. */ -public fun IntRange.contains(item: Double): Boolean { +platformName("intRangeContains") +public fun Range.contains(item: Double): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun LongRange.contains(item: Double): Boolean { +platformName("longRangeContains") +public fun Range.contains(item: Double): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ByteRange.contains(item: Double): Boolean { +platformName("byteRangeContains") +public fun Range.contains(item: Double): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ShortRange.contains(item: Double): Boolean { +platformName("shortRangeContains") +public fun Range.contains(item: Double): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun FloatRange.contains(item: Double): Boolean { +platformName("floatRangeContains") +public fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -123,35 +133,40 @@ public fun CharRange.contains(item: Double): Nothing { /** * Checks if the specified [item] belongs to this range. */ -public fun IntRange.contains(item: Float): Boolean { +platformName("intRangeContains") +public fun Range.contains(item: Float): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun LongRange.contains(item: Float): Boolean { +platformName("longRangeContains") +public fun Range.contains(item: Float): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ByteRange.contains(item: Float): Boolean { +platformName("byteRangeContains") +public fun Range.contains(item: Float): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ShortRange.contains(item: Float): Boolean { +platformName("shortRangeContains") +public fun Range.contains(item: Float): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun DoubleRange.contains(item: Float): Boolean { +platformName("doubleRangeContains") +public fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -163,35 +178,40 @@ public fun CharRange.contains(item: Float): Nothing { /** * Checks if the specified [item] belongs to this range. */ -public fun LongRange.contains(item: Int): Boolean { +platformName("longRangeContains") +public fun Range.contains(item: Int): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ByteRange.contains(item: Int): Boolean { +platformName("byteRangeContains") +public fun Range.contains(item: Int): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ShortRange.contains(item: Int): Boolean { +platformName("shortRangeContains") +public fun Range.contains(item: Int): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun DoubleRange.contains(item: Int): Boolean { +platformName("doubleRangeContains") +public fun Range.contains(item: Int): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun FloatRange.contains(item: Int): Boolean { +platformName("floatRangeContains") +public fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -203,35 +223,40 @@ public fun CharRange.contains(item: Int): Nothing { /** * Checks if the specified [item] belongs to this range. */ -public fun IntRange.contains(item: Long): Boolean { +platformName("intRangeContains") +public fun Range.contains(item: Long): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ByteRange.contains(item: Long): Boolean { +platformName("byteRangeContains") +public fun Range.contains(item: Long): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ShortRange.contains(item: Long): Boolean { +platformName("shortRangeContains") +public fun Range.contains(item: Long): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun DoubleRange.contains(item: Long): Boolean { +platformName("doubleRangeContains") +public fun Range.contains(item: Long): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun FloatRange.contains(item: Long): Boolean { +platformName("floatRangeContains") +public fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -243,35 +268,40 @@ public fun CharRange.contains(item: Long): Nothing { /** * Checks if the specified [item] belongs to this range. */ -public fun IntRange.contains(item: Short): Boolean { +platformName("intRangeContains") +public fun Range.contains(item: Short): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun LongRange.contains(item: Short): Boolean { +platformName("longRangeContains") +public fun Range.contains(item: Short): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun ByteRange.contains(item: Short): Boolean { +platformName("byteRangeContains") +public fun Range.contains(item: Short): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun DoubleRange.contains(item: Short): Boolean { +platformName("doubleRangeContains") +public fun Range.contains(item: Short): Boolean { return start <= item && item <= end } /** * Checks if the specified [item] belongs to this range. */ -public fun FloatRange.contains(item: Short): Boolean { +platformName("floatRangeContains") +public fun Range.contains(item: Short): Boolean { return start <= item && item <= end } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt index f731cfe254e..0b42fc0e114 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt @@ -118,15 +118,18 @@ fun ranges(): List { .map { until(it.first, it.second) } fun contains(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") { - only(RangesOfPrimitives) - only(rangeType) val meaningless = (rangeType.isNumeric() != itemType.isNumeric()) if (!meaningless) { + only(Ranges) + onlyPrimitives(Ranges, rangeType) + platformName("${rangeType.name.decapitalize()}RangeContains") returns("Boolean") doc { "Checks if the specified [item] belongs to this range." } body { "return start <= item && item <= end" } } else { + only(RangesOfPrimitives) + only(rangeType) returns("Nothing") annotations("""deprecated("The 'contains' operation for a range of $rangeType and $itemType item is not supported and should not be used.")""") body { """throw UnsupportedOperationException()""" }