Do not generate deprecated contains for ranges.
This commit is contained in:
@@ -52,41 +52,6 @@ public operator fun Range<Float>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Byte item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Byte): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Int and Char item is not supported and should not be used.")
|
||||
public operator fun IntRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Long and Char item is not supported and should not be used.")
|
||||
public operator fun LongRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Byte and Char item is not supported and should not be used.")
|
||||
public operator fun ByteRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Short and Char item is not supported and should not be used.")
|
||||
public operator fun ShortRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Double and Char item is not supported and should not be used.")
|
||||
public operator fun DoubleRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Float and Char item is not supported and should not be used.")
|
||||
public operator fun FloatRange.contains(item: Char): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@@ -127,11 +92,6 @@ public operator fun Range<Float>.contains(item: Double): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Double item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Double): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@@ -172,11 +132,6 @@ public operator fun Range<Double>.contains(item: Float): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Float item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Float): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@@ -217,11 +172,6 @@ public operator fun Range<Float>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Int item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Int): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@@ -262,11 +212,6 @@ public operator fun Range<Float>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Long item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Long): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@@ -307,11 +252,6 @@ public operator fun Range<Float>.contains(item: Short): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
|
||||
@Deprecated("The 'contains' operation for a range of Char and Short item is not supported and should not be used.")
|
||||
public operator fun CharRange.contains(item: Short): Nothing {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
|
||||
@@ -129,27 +129,17 @@ fun ranges(): List<GenericFunction> {
|
||||
fun contains(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") {
|
||||
operator(true)
|
||||
|
||||
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()""" }
|
||||
}
|
||||
assert(rangeType.isNumeric() != itemType.isNumeric())
|
||||
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" }
|
||||
}
|
||||
|
||||
val allPermutations = (numericPrimitives + PrimitiveType.Char).let { it.flatMap { from -> it.map { to -> from to to } }}
|
||||
|
||||
templates addAll allPermutations.filter { it.first != it.second }.map { contains(it.first, it.second) }
|
||||
templates addAll numericPermutations.filter { it.first != it.second }.map { contains(it.first, it.second) }
|
||||
|
||||
return templates
|
||||
}
|
||||
Reference in New Issue
Block a user