Using empty ranges in downTo generator.

This commit is contained in:
Evgeny Gerashchenko
2012-08-09 13:56:56 +04:00
parent 543ec16f4d
commit 8084876fed
2 changed files with 26 additions and 27 deletions
@@ -28,10 +28,9 @@ public inline fun $fromType.downTo(to: $toType): $rangeType {
return $rangeType($fromExpr, to - this)
}""")
} else {
// TODO use empty range constant, which is not available yet (KT-2583)
writer.println("""
public inline fun $fromType.downTo(to: $toType): $rangeType {
return if (this >= to) $rangeType($fromExpr, to - this - 1) else $rangeType(${if (elementType == "Char") "0.toChar()" else "0"}, 0)
return if (this >= to) $rangeType($fromExpr, to - this - 1) else $rangeType.EMPTY
}""")
}
}