[K2] Support proper serialization of string concatenation expressions
This commit is contained in:
+10
@@ -73,6 +73,12 @@ private abstract class FirToConstantValueTransformer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: FirSession): ConstantValue<*>? {
|
||||||
|
val strings = stringConcatenationCall.argumentList.arguments.map { it.accept(this, data) }
|
||||||
|
if (strings.any { it == null || it !is StringValue }) return null
|
||||||
|
return StringValue(strings.joinToString(separator = "") { (it as StringValue).value })
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitArrayOfCall(
|
override fun visitArrayOfCall(
|
||||||
arrayOfCall: FirArrayOfCall,
|
arrayOfCall: FirArrayOfCall,
|
||||||
data: FirSession
|
data: FirSession
|
||||||
@@ -208,6 +214,10 @@ internal object FirToConstantValueChecker : FirDefaultVisitor<Boolean, FirSessio
|
|||||||
return constExpression.kind in supportedConstKinds
|
return constExpression.kind in supportedConstKinds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall, data: FirSession): Boolean {
|
||||||
|
return stringConcatenationCall.argumentList.arguments.all { it.accept(this, data) }
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitArrayOfCall(arrayOfCall: FirArrayOfCall, data: FirSession): Boolean {
|
override fun visitArrayOfCall(arrayOfCall: FirArrayOfCall, data: FirSession): Boolean {
|
||||||
return arrayOfCall.arguments.all { it.accept(this, data) }
|
return arrayOfCall.arguments.all { it.accept(this, data) }
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
object Obj {
|
||||||
|
const val O = "O"
|
||||||
|
val concat = "${O}K"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("${Obj.O}/{id}")
|
||||||
|
class Foo
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package <root> {
|
||||||
|
@Deprecated(message = "O/{id}") class Foo constructor()
|
||||||
|
object Obj {
|
||||||
|
const val O: String = "O"
|
||||||
|
val concat: String = "OK"
|
||||||
|
}
|
||||||
+40
@@ -24832,6 +24832,46 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
|||||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/unsignedConst.kt");
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/unsignedConst.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/involvesIrInterpreter/serialization")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@Tag("codegenK2")
|
||||||
|
@Tag("firCodegen")
|
||||||
|
@UseExtTestCaseGroupProvider()
|
||||||
|
@FirPipeline()
|
||||||
|
@UsePartialLinkage(mode = Mode.DISABLED)
|
||||||
|
@Tag("no-partial-linkage-may-be-skipped")
|
||||||
|
public class Serialization {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInSerialization() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/involvesIrInterpreter/serialization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationInArguments.kt")
|
||||||
|
public void testAnnotationInArguments() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationInArguments.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationSerialization.kt")
|
||||||
|
public void testAnnotationSerialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationSerialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationWithArray.kt")
|
||||||
|
public void testAnnotationWithArray() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationWithArray.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationWithDefaults.kt")
|
||||||
|
public void testAnnotationWithDefaults() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationWithDefaults.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -125,6 +125,12 @@ public class FirNativeKLibContentsTestGenerated extends AbstractNativeKlibConten
|
|||||||
runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt");
|
runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("stringConcatenation.kt")
|
||||||
|
public void testStringConcatenation() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibContents/builtinsSerializer/stringConcatenation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("typeParameterAnnotation.kt")
|
@TestMetadata("typeParameterAnnotation.kt")
|
||||||
public void testTypeParameterAnnotation() throws Exception {
|
public void testTypeParameterAnnotation() throws Exception {
|
||||||
|
|||||||
+39
@@ -24597,6 +24597,45 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
|||||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/unsignedConst.kt");
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/unsignedConst.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/box/involvesIrInterpreter/serialization")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@Tag("codegen")
|
||||||
|
@Tag("k1Codegen")
|
||||||
|
@UseExtTestCaseGroupProvider()
|
||||||
|
@UsePartialLinkage(mode = Mode.DISABLED)
|
||||||
|
@Tag("no-partial-linkage-may-be-skipped")
|
||||||
|
public class Serialization {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInSerialization() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/involvesIrInterpreter/serialization"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationInArguments.kt")
|
||||||
|
public void testAnnotationInArguments() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationInArguments.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationSerialization.kt")
|
||||||
|
public void testAnnotationSerialization() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationSerialization.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationWithArray.kt")
|
||||||
|
public void testAnnotationWithArray() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationWithArray.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationWithDefaults.kt")
|
||||||
|
public void testAnnotationWithDefaults() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/involvesIrInterpreter/serialization/annotationWithDefaults.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+6
@@ -120,6 +120,12 @@ public class NativeKLibContentsTestGenerated extends AbstractNativeKlibContentsT
|
|||||||
runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt");
|
runTest("native/native.tests/testData/klibContents/builtinsSerializer/sourceRetainedAnnotation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("stringConcatenation.kt")
|
||||||
|
public void testStringConcatenation() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/klibContents/builtinsSerializer/stringConcatenation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("typeParameterAnnotation.kt")
|
@TestMetadata("typeParameterAnnotation.kt")
|
||||||
public void testTypeParameterAnnotation() throws Exception {
|
public void testTypeParameterAnnotation() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user