Minor, fix warnings on new stdlib API

In modules where allWarningsAsErrors is not yet enabled.
This commit is contained in:
Alexander Udalov
2021-04-09 17:20:07 +02:00
parent e89ab71bf8
commit 168d8b07a8
8 changed files with 14 additions and 14 deletions
@@ -29,11 +29,11 @@ object WobblyTF8 {
if (char1 < '\u0080') { if (char1 < '\u0080') {
// U+0000..U+007F -> 0xxxxxxx // U+0000..U+007F -> 0xxxxxxx
// 7 meaningful bits -> 1 byte // 7 meaningful bits -> 1 byte
buffer[writtenBytes++] = char1.toInt() buffer[writtenBytes++] = char1.code
} else if (char1 < '\u0800') { } else if (char1 < '\u0800') {
// U+0080..U+07FF -> 110xxxxx 10xxxxxx // U+0080..U+07FF -> 110xxxxx 10xxxxxx
// 11 meaningful bits -> 2 bytes // 11 meaningful bits -> 2 bytes
val codePoint = char1.toInt() val codePoint = char1.code
buffer[writtenBytes++] = (codePoint ushr 6) or 0b1100_0000 buffer[writtenBytes++] = (codePoint ushr 6) or 0b1100_0000
buffer[writtenBytes++] = (codePoint and 0b0011_1111) or 0b1000_0000 buffer[writtenBytes++] = (codePoint and 0b0011_1111) or 0b1000_0000
} else { } else {
@@ -55,7 +55,7 @@ object WobblyTF8 {
// U+0800..U+FFFF -> 1110xxxx 10xxxxxx 10xxxxxx // U+0800..U+FFFF -> 1110xxxx 10xxxxxx 10xxxxxx
// 16 meaningful bits -> 3 bytes // 16 meaningful bits -> 3 bytes
val codePoint = char1.toInt() val codePoint = char1.code
buffer[writtenBytes++] = (codePoint ushr 12) or 0b1110_0000 buffer[writtenBytes++] = (codePoint ushr 12) or 0b1110_0000
buffer[writtenBytes++] = ((codePoint ushr 6) and 0b0011_1111) or 0b1000_0000 buffer[writtenBytes++] = ((codePoint ushr 6) and 0b0011_1111) or 0b1000_0000
buffer[writtenBytes++] = (codePoint and 0b0011_1111) or 0b1000_0000 buffer[writtenBytes++] = (codePoint and 0b0011_1111) or 0b1000_0000
@@ -152,9 +152,9 @@ class WobblyTF8Test {
fun ByteArray.decodeWithWobbly(): String = WobblyTF8.decode(this) fun ByteArray.decodeWithWobbly(): String = WobblyTF8.decode(this)
fun ByteArray.decodeWithUTF8(): String = toString(Charsets.UTF_8) fun ByteArray.decodeWithUTF8(): String = toString(Charsets.UTF_8)
val CODE_POINTS_BEFORE_SURROGATES = MIN_CODE_POINT until MIN_SURROGATE.toInt() val CODE_POINTS_BEFORE_SURROGATES = MIN_CODE_POINT until MIN_SURROGATE.code
val CODE_POINTS_SURROGATES = MIN_SURROGATE.toInt()..MAX_SURROGATE.toInt() val CODE_POINTS_SURROGATES = MIN_SURROGATE.code..MAX_SURROGATE.code
val CODE_POINTS_AFTER_SURROGATES = (MAX_SURROGATE.toInt() + 1) until MIN_SUPPLEMENTARY_CODE_POINT val CODE_POINTS_AFTER_SURROGATES = (MAX_SURROGATE.code + 1) until MIN_SUPPLEMENTARY_CODE_POINT
val CODE_POINTS_SUPPLEMENTARY = MIN_SUPPLEMENTARY_CODE_POINT..MAX_CODE_POINT val CODE_POINTS_SUPPLEMENTARY = MIN_SUPPLEMENTARY_CODE_POINT..MAX_CODE_POINT
fun generateWellFormedString( fun generateWellFormedString(
@@ -58,10 +58,10 @@ object HLDiagnosticConverter {
} }
private fun DiagnosticData.getHLDiagnosticClassName() = private fun DiagnosticData.getHLDiagnosticClassName() =
name.toLowerCase() name.lowercase()
.split('_') .split('_')
.joinToString(separator = "") { .joinToString(separator = "") {
it.capitalize() it.replaceFirstChar(Char::uppercaseChar)
} }
private fun DiagnosticData.getHLDiagnosticImplClassName() = private fun DiagnosticData.getHLDiagnosticImplClassName() =
@@ -37,7 +37,7 @@ fun ProtoBuf.Annotation.Argument.Value.readAnnotationArgument(strings: NameResol
return when (type) { return when (type) {
BYTE -> KmAnnotationArgument.ByteValue(intValue.toByte()) BYTE -> KmAnnotationArgument.ByteValue(intValue.toByte())
CHAR -> KmAnnotationArgument.CharValue(intValue.toChar()) CHAR -> KmAnnotationArgument.CharValue(intValue.toInt().toChar())
SHORT -> KmAnnotationArgument.ShortValue(intValue.toShort()) SHORT -> KmAnnotationArgument.ShortValue(intValue.toShort())
INT -> KmAnnotationArgument.IntValue(intValue.toInt()) INT -> KmAnnotationArgument.IntValue(intValue.toInt())
LONG -> KmAnnotationArgument.LongValue(intValue) LONG -> KmAnnotationArgument.LongValue(intValue)
@@ -34,7 +34,7 @@ fun KmAnnotationArgument.writeAnnotationArgument(strings: StringTable): ProtoBuf
} }
is KmAnnotationArgument.CharValue -> { is KmAnnotationArgument.CharValue -> {
this.type = ProtoBuf.Annotation.Argument.Value.Type.CHAR this.type = ProtoBuf.Annotation.Argument.Value.Type.CHAR
this.intValue = value.toLong() this.intValue = value.code.toLong()
} }
is KmAnnotationArgument.ShortValue -> { is KmAnnotationArgument.ShortValue -> {
this.type = ProtoBuf.Annotation.Argument.Value.Type.SHORT this.type = ProtoBuf.Annotation.Argument.Value.Type.SHORT
@@ -85,7 +85,7 @@ public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequenc
@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }")) @Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }"))
@DeprecatedSinceKotlin(warningSince = "1.5") @DeprecatedSinceKotlin(warningSince = "1.5")
public actual fun String.capitalize(): String { public actual fun String.capitalize(): String {
return if (isNotEmpty()) substring(0, 1).toUpperCase() + substring(1) else this return if (isNotEmpty()) substring(0, 1).uppercase() + substring(1) else this
} }
/** /**
@@ -97,7 +97,7 @@ public actual fun String.capitalize(): String {
@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase() }")) @Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase() }"))
@DeprecatedSinceKotlin(warningSince = "1.5") @DeprecatedSinceKotlin(warningSince = "1.5")
public actual fun String.decapitalize(): String { public actual fun String.decapitalize(): String {
return if (isNotEmpty()) substring(0, 1).toLowerCase() + substring(1) else this return if (isNotEmpty()) substring(0, 1).lowercase() + substring(1) else this
} }
/** /**
@@ -122,7 +122,7 @@ public class SequenceTest {
data.forEach { } data.forEach { }
assertEquals(0, count, "onEach should be executed only when resulting sequence is iterated") assertEquals(0, count, "onEach should be executed only when resulting sequence is iterated")
val sum = newData.sumBy { it.length } val sum = newData.sumOf { it.length }
assertEquals(sum, count) assertEquals(sum, count)
} }
@@ -484,7 +484,7 @@ private fun String.sanitize(quote: Char): String =
'\r' -> append("\\r") '\r' -> append("\\r")
'\t' -> append("\\t") '\t' -> append("\\t")
quote -> append("\\").append(quote) quote -> append("\\").append(quote)
else -> append(if (c.isISOControl()) "\\u%04x".format(c.toInt()) else c) else -> append(if (c.isISOControl()) "\\u%04x".format(c.code) else c)
} }
} }
} }