From d0b62df0460daa444805a5177a4955f782196d0c Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 9 Apr 2025 14:30:07 +0200 Subject: feat: Port to K2 / Kotlin 2.1.20 / KSP 2.0.0 --- .../kotlin/MCAutoTranslationsCallTransformerAndCollector.kt | 12 ++++++------ .../moe/nea/mcautotranslations/TestTemplateReplacement.kt | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'kotlin-plugin/src') diff --git a/kotlin-plugin/src/main/kotlin/moe/nea/mcautotranslations/kotlin/MCAutoTranslationsCallTransformerAndCollector.kt b/kotlin-plugin/src/main/kotlin/moe/nea/mcautotranslations/kotlin/MCAutoTranslationsCallTransformerAndCollector.kt index d87648d..822be0f 100644 --- a/kotlin-plugin/src/main/kotlin/moe/nea/mcautotranslations/kotlin/MCAutoTranslationsCallTransformerAndCollector.kt +++ b/kotlin-plugin/src/main/kotlin/moe/nea/mcautotranslations/kotlin/MCAutoTranslationsCallTransformerAndCollector.kt @@ -86,8 +86,8 @@ class MCAutoTranslationsCallTransformerAndCollector( val varArgs = irVararg(context.irBuiltIns.anyType.makeNullable(), arguments) return irCall( - replacementFunction, replacementFunction.owner.returnType, - valueArgumentsCount = 2, + replacementFunction, + replacementFunction.owner.returnType, ).apply { putValueArgument(0, constString(key, keySource.startOffset, keySource.endOffset)) @@ -139,8 +139,8 @@ class MCAutoTranslationsCallTransformerAndCollector( text: String, startOffset: Int = SYNTHETIC_OFFSET, endOffset: Int = SYNTHETIC_OFFSET - ): IrConst = - text.toIrConst(irPluginContext.irBuiltIns.stringType, startOffset, endOffset) as IrConst + ): IrConst = + text.toIrConst(irPluginContext.irBuiltIns.stringType, startOffset, endOffset) } data class StringTemplate( @@ -150,13 +150,13 @@ data class StringTemplate( } fun IrExpression?.asStringDyn(): StringTemplate? = when (this) { - is IrConst<*> -> if (kind == IrConstKind.String) StringTemplate(this) else null + is IrConst -> if (kind == IrConstKind.String) StringTemplate(this) else null is IrStringConcatenation -> StringTemplate(this.arguments) else -> null } fun IrExpression?.asStringConst(): String? = when (this) { - is IrConst<*> -> if (kind == IrConstKind.String) value as String else null + is IrConst -> if (kind == IrConstKind.String) value as String else null is IrStringConcatenation -> this.arguments.singleOrNull().asStringConst() else -> null } diff --git a/kotlin-plugin/src/test/kotlin/moe/nea/mcautotranslations/TestTemplateReplacement.kt b/kotlin-plugin/src/test/kotlin/moe/nea/mcautotranslations/TestTemplateReplacement.kt index b4a7f18..a62ac30 100644 --- a/kotlin-plugin/src/test/kotlin/moe/nea/mcautotranslations/TestTemplateReplacement.kt +++ b/kotlin-plugin/src/test/kotlin/moe/nea/mcautotranslations/TestTemplateReplacement.kt @@ -10,7 +10,7 @@ class TestTemplateReplacement { @Test fun testX() { val dollar = '$' - compile(listOf( + val result = compile(listOf( SourceFile.kotlin( "test.kt", """ @@ -37,4 +37,4 @@ class TestTemplateReplacement { ) )) } -} \ No newline at end of file +} -- cgit