diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/YamlElement.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/YamlElement.kt index c117ce7..400892c 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/YamlElement.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/YamlElement.kt @@ -103,7 +103,6 @@ public fun YamlElement.asLiteralOrNull(): YamlLiteral? { /** * @return [this] as a [YamlLiteral], `null` otherwise */ -@OptIn(ExperimentalContracts::class) public inline fun YamlElement.asLiteral( crossinline lazyMessage: (YamlElement) -> String = { "$this is not a YamlLiteral" } ): YamlLiteral { @@ -125,7 +124,6 @@ public fun YamlElement.asPrimitiveOrNull(): YamlPrimitive? { /** * @return [this] as a [YamlPrimitive], `null` otherwise */ -@OptIn(ExperimentalContracts::class) public inline fun YamlElement.asPrimitive( crossinline lazyMessage: (YamlElement) -> String = { "$this is not a YamlPrimitive" } ): YamlPrimitive { @@ -135,7 +133,6 @@ public inline fun YamlElement.asPrimitive( /** * @return [YamlLiteral.content] if this is a [YamlLiteral], `null` otherwise */ -@OptIn(ExperimentalContracts::class) public val YamlElement.literalContentOrNull: String? get() = (this as? YamlLiteral)?.content @@ -515,7 +512,7 @@ internal fun Any?.asYamlElementOrNullImpl(): YamlElement? = when (this) { else -> null } -@Suppress("UNCHECKED_CAST", "IMPLICIT_CAST_TO_ANY") +@Suppress("UNCHECKED_CAST") @PublishedApi internal fun YamlElement.smartCastPrimitive(clazz: KClass): R { // reduce inlined bytecode size require(this is YamlPrimitive) { "the element is not YamlPrimitive" } diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Converters.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Converters.kt index 2d872f3..33d19b2 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Converters.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Converters.kt @@ -9,10 +9,7 @@ import kotlin.jvm.JvmName import kotlin.math.pow // No generic type: Long will be transformed to primitive `long` on JVM, best performance -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -// TODO(#27): This breaks the compiler -// @kotlin.internal.InlineOnly -private inline fun CharSequence.foldFromRightOffsetIndexed( +private fun CharSequence.foldFromRightOffsetIndexed( offset: Int, initial: Long, operation: (index: Int, acc: Long, Char) -> Long @@ -29,9 +26,6 @@ private inline fun CharSequence.foldFromRightOffsetIndexed( } // No generic type: Long will be transformed to primitive `long` on JVM, best performance -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -// TODO(#27): This breaks the compiler -// @kotlin.internal.InlineOnly private inline fun CharArray.foldFromRightOffsetIndexed( offset: Int, length: Int, @@ -91,7 +85,6 @@ internal object HexConverter { * The converter that converts binary [String]s from or to numbers */ internal object BinaryConverter { - @OptIn(ExperimentalUnsignedTypes::class) private val BINARY_POW_TABLE: Array = Array(Long.SIZE_BITS) { 2.0.pow(it).toULong().toLong() } fun binToLong(value: String, offset: Int): Long { @@ -124,14 +117,12 @@ internal fun Long.limitToInt(): Int { } // this is very frequently used -@Suppress("NOTHING_TO_INLINE") -internal inline fun String.optimizeNull(): String? = when (this) { +internal fun String.optimizeNull(): String? = when (this) { "~", "null", "NULL" -> null else -> this } -@Suppress("NOTHING_TO_INLINE") -internal inline fun Any.classSimpleName(): String? { +internal fun Any.classSimpleName(): String? { return this::class.simpleName } \ No newline at end of file diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/DynamicSerializersUtils.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/DynamicSerializersUtils.kt index 5c6d0ad..6e2a2cf 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/DynamicSerializersUtils.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/DynamicSerializersUtils.kt @@ -37,7 +37,6 @@ internal interface IYamlDynamicSerializer internal expect fun IYamlDynamicSerializer.serializeImpl(encoder: Encoder, value: Any) -@Suppress("RemoveExplicitTypeArguments") // compiler bug internal object AnyTypedArraySerializer : KSerializer> by ArraySerializer(YamlNullableDynamicSerializer) diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Escape.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Escape.kt index 0c2672d..8301ed2 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Escape.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Escape.kt @@ -1,6 +1,5 @@ @file:JvmMultifileClass @file:JvmName("YamlUtils") -@file:Suppress("NOTHING_TO_INLINE") package net.mamoe.yamlkt.internal @@ -486,7 +485,7 @@ private tailrec fun TokenStream.runNewLineSkippingAndEscapingForUnquoted( } } -internal inline fun TokenStream.ensureNotEOF() { +internal fun TokenStream.ensureNotEOF() { if (endOfInput) throw contextualDecodingException("Unexpected EOF") } @@ -601,7 +600,7 @@ internal inline fun TokenStream.peekNext(block: (ch: Char) -> R?): R? { return source[cur + 1].let(block) } -internal inline fun Char.isHexDigit(): Boolean = this in '0'..'9' || this in 'a'..'f' || this in 'A'..'F' +internal fun Char.isHexDigit(): Boolean = this in '0'..'9' || this in 'a'..'f' || this in 'A'..'F' internal fun String.toEscapedString( buf: StringBufHolder, @@ -641,7 +640,7 @@ private fun String.toDoubleQuotedString(buf: StringBufHolder): String = with(buf takeStringBuf() } -private inline infix fun Int.hasFlag(flag: Int): Boolean = this and flag != 0 +private infix fun Int.hasFlag(flag: Int): Boolean = this and flag != 0 private const val SINGLE = /* */ 0b001 private const val UNQUOTED = /* */ 0b010 diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Inline.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Inline.kt index fa42a43..b073a7e 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Inline.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/Inline.kt @@ -6,7 +6,6 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.modules.SerializersModule -@OptIn(ExperimentalUnsignedTypes::class) internal class InlineEncoder( private val writer: YamlWriter, private val encoder: Encoder, @@ -18,7 +17,6 @@ internal class InlineEncoder( override fun encodeShort(value: Short) = writer.write(value.toUShort().toString()) } -@OptIn(ExperimentalUnsignedTypes::class) internal class InlineDecoder( private val delegate: YamlDecoder, ) : Decoder by delegate { @@ -35,7 +33,6 @@ internal class InlineDecoder( delegate.run { decodeString().withIntegerValue("ULong", null, -1).toULong().toLong() } } -@OptIn(ExperimentalUnsignedTypes::class) internal class InlineElementDecoder( private val yamlDecoder: YamlDecoder, private val compositeDecoder: YamlDecoder.AbstractDecoder, diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlDecoder.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlDecoder.kt index 70b10e7..4bf3ab9 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlDecoder.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlDecoder.kt @@ -1172,7 +1172,7 @@ internal class YamlDecoder( } } -internal inline fun Int.isOdd(): Boolean { +internal fun Int.isOdd(): Boolean { return this and 0b1 != 0 } diff --git a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlWriter.kt b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlWriter.kt index 98b3a7a..ce1e761 100644 --- a/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlWriter.kt +++ b/yamlkt/src/commonMain/kotlin/net.mamoe.yamlkt/internal/YamlWriter.kt @@ -1,8 +1,6 @@ @file:JvmMultifileClass @file:JvmName("YamlUtils") -@file:Suppress("NOTHING_TO_INLINE") - package net.mamoe.yamlkt.internal import kotlin.jvm.JvmField @@ -32,23 +30,23 @@ internal class YamlWriter( level-- } - inline fun append(char: Char) { + fun append(char: Char) { if (char == '\n') { currentIndent = 0 } else currentIndent++ output.append(char) } - inline fun append(char: String) { // String doesn't matter indenting + fun append(char: String) { // String doesn't matter indenting currentIndent += char.length output.append(char) } - inline operator fun String.unaryPlus() { + operator fun String.unaryPlus() { write(this) } - inline operator fun Char.unaryPlus() { + operator fun Char.unaryPlus() { write(this) } @@ -56,20 +54,20 @@ internal class YamlWriter( internal val escapeBuf: StringBufHolder = StringBufHolder() } -internal inline fun YamlWriter.write(char: Char) { +internal fun YamlWriter.write(char: Char) { append(char) } -internal inline fun YamlWriter.writeln(char: Char) { +internal fun YamlWriter.writeln(char: Char) { write(char) writeln() } -internal inline fun YamlWriter.writeln() { +internal fun YamlWriter.writeln() { write('\n') } -internal inline fun YamlWriter.write(chars: String) { +internal fun YamlWriter.write(chars: String) { append(chars) } @@ -84,17 +82,17 @@ internal inline fun YamlWriter.writeLineIndented(line: YamlWriter.() -> Unit) { writeln() } -internal inline fun YamlWriter.writeln(chars: String) { +internal fun YamlWriter.writeln(chars: String) { write(chars) writeln() } -internal inline fun YamlWriter.writelnIndented(chars: String) { +internal fun YamlWriter.writelnIndented(chars: String) { writeIndented(chars) writeln() } -internal inline fun YamlWriter.writeIndented(chars: String) { +internal fun YamlWriter.writeIndented(chars: String) { writeIndent() write(chars) } @@ -115,18 +113,18 @@ internal fun YamlWriter.writeIndentSmart() { } } -internal inline fun YamlWriter.writelnIndented(char: Char) { +internal fun YamlWriter.writelnIndented(char: Char) { writeIndented(char) writeln() } -internal inline fun YamlWriter.writeIndent() { +internal fun YamlWriter.writeIndent() { repeat(level) { write(INDENT_STRING) } } -internal inline fun YamlWriter.writeIndented(char: Char) { +internal fun YamlWriter.writeIndented(char: Char) { writeIndent() write(char) }