Deprecate meaningless or vague-defined operations with Char operands: downTo.

This commit is contained in:
Ilya Gorbunov
2015-05-29 23:47:05 +03:00
parent 8a751ad74a
commit 64b2e37436
2 changed files with 20 additions and 2 deletions
+12
View File
@@ -20,6 +20,7 @@ public fun Byte.downTo(to: Byte): ByteProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Byte.downTo(to: Char): CharProgression { public fun Byte.downTo(to: Char): CharProgression {
return CharProgression(this.toChar(), to, -1) return CharProgression(this.toChar(), to, -1)
} }
@@ -74,6 +75,7 @@ public fun Byte.downTo(to: Double): DoubleProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Byte): CharProgression { public fun Char.downTo(to: Byte): CharProgression {
return CharProgression(this, to.toChar(), -1) return CharProgression(this, to.toChar(), -1)
} }
@@ -92,6 +94,7 @@ public fun Char.downTo(to: Char): CharProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Short): ShortProgression { public fun Char.downTo(to: Short): ShortProgression {
return ShortProgression(this.toShort(), to, -1) return ShortProgression(this.toShort(), to, -1)
} }
@@ -101,6 +104,7 @@ public fun Char.downTo(to: Short): ShortProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Int): IntProgression { public fun Char.downTo(to: Int): IntProgression {
return IntProgression(this.toInt(), to, -1) return IntProgression(this.toInt(), to, -1)
} }
@@ -110,6 +114,7 @@ public fun Char.downTo(to: Int): IntProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Long): LongProgression { public fun Char.downTo(to: Long): LongProgression {
return LongProgression(this.toLong(), to, -1.toLong()) return LongProgression(this.toLong(), to, -1.toLong())
} }
@@ -119,6 +124,7 @@ public fun Char.downTo(to: Long): LongProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Float): FloatProgression { public fun Char.downTo(to: Float): FloatProgression {
return FloatProgression(this.toFloat(), to, -1.toFloat()) return FloatProgression(this.toFloat(), to, -1.toFloat())
} }
@@ -128,6 +134,7 @@ public fun Char.downTo(to: Float): FloatProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Char.downTo(to: Double): DoubleProgression { public fun Char.downTo(to: Double): DoubleProgression {
return DoubleProgression(this.toDouble(), to, -1.0) return DoubleProgression(this.toDouble(), to, -1.0)
} }
@@ -146,6 +153,7 @@ public fun Short.downTo(to: Byte): ShortProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Short.downTo(to: Char): ShortProgression { public fun Short.downTo(to: Char): ShortProgression {
return ShortProgression(this, to.toShort(), -1) return ShortProgression(this, to.toShort(), -1)
} }
@@ -209,6 +217,7 @@ public fun Int.downTo(to: Byte): IntProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Int.downTo(to: Char): IntProgression { public fun Int.downTo(to: Char): IntProgression {
return IntProgression(this, to.toInt(), -1) return IntProgression(this, to.toInt(), -1)
} }
@@ -272,6 +281,7 @@ public fun Long.downTo(to: Byte): LongProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Long.downTo(to: Char): LongProgression { public fun Long.downTo(to: Char): LongProgression {
return LongProgression(this, to.toLong(), -1.toLong()) return LongProgression(this, to.toLong(), -1.toLong())
} }
@@ -335,6 +345,7 @@ public fun Float.downTo(to: Byte): FloatProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Float.downTo(to: Char): FloatProgression { public fun Float.downTo(to: Char): FloatProgression {
return FloatProgression(this, to.toFloat(), -1.toFloat()) return FloatProgression(this, to.toFloat(), -1.toFloat())
} }
@@ -398,6 +409,7 @@ public fun Double.downTo(to: Byte): DoubleProgression {
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
public fun Double.downTo(to: Char): DoubleProgression { public fun Double.downTo(to: Char): DoubleProgression {
return DoubleProgression(this, to.toDouble(), -1.0) return DoubleProgression(this, to.toDouble(), -1.0)
} }
@@ -31,15 +31,21 @@ private fun generateDownTos(outputFile: File, header: String) {
else -> "-1" else -> "-1"
} }
val deprecated =
if ((fromType == "Char") != (toType == "Char")) {
"""deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")"""
} else ""
writer.println(""" writer.println("""
/** /**
* Returns a progression from this value down to the specified [to] value. * Returns a progression from this value down to the specified [to] value.
* *
* The [to] value has to be less than this value. * The [to] value has to be less than this value.
*/ */
$deprecated
public fun $fromType.downTo(to: $toType): $progressionType { public fun $fromType.downTo(to: $toType): $progressionType {
return $progressionType($fromExpr, $toExpr, $incrementExpr) return $progressionType($fromExpr, $toExpr, $incrementExpr)
}""") }""".replace("\n\n","\n"))
} }
println("Writing $outputFile") println("Writing $outputFile")
@@ -53,7 +59,7 @@ public fun $fromType.downTo(to: $toType): $progressionType {
$COMMON_AUTOGENERATED_WARNING $COMMON_AUTOGENERATED_WARNING
""") """)
val types = array("Byte", "Char", "Short", "Int", "Long", "Float", "Double") val types = arrayOf("Byte", "Char", "Short", "Int", "Long", "Float", "Double")
for (fromType in types) { for (fromType in types) {
for (toType in types) { for (toType in types) {
generateDownTo(writer, fromType, toType) generateDownTo(writer, fromType, toType)