[FIR2IR] Consider property init value from nested class, ^KT-52057 Fixed

This commit is contained in:
Ivan Kochurkin
2022-04-20 00:07:17 +03:00
parent 48c4d4cf21
commit 0ef043b074
11 changed files with 76 additions and 2 deletions
@@ -76,6 +76,12 @@ fun deserializeClassToSymbol(
containerSource,
symbol,
annotationDeserializer,
if (status.isCompanion) {
parentContext.constDeserializer
} else {
((containerSource as? KotlinJvmBinarySourceElement)?.binaryClass)?.let { FirConstDeserializer(session, it) }
?: parentContext.constDeserializer
},
status.isInner
) ?: FirDeserializationContext.createForClass(
classId,
@@ -203,9 +209,9 @@ fun deserializeClassToSymbol(
}
it.setSealedClassInheritors(inheritors)
}
it.valueClassRepresentation = computeValueClassRepresentation(it, session)
(it.annotations as MutableList<FirAnnotation>) +=
context.annotationDeserializer.loadClassAnnotations(classProto, context.nameResolver)
@@ -65,6 +65,7 @@ class FirDeserializationContext(
containerSource: DeserializedContainerSource? = this.containerSource,
outerClassSymbol: FirRegularClassSymbol? = this.outerClassSymbol,
annotationDeserializer: AbstractAnnotationDeserializer = this.annotationDeserializer,
constDeserializer: FirConstDeserializer = this.constDeserializer,
capturesTypeParameters: Boolean = true,
containingDeclarationSymbol: FirBasedSymbol<*>? = this.outerClassSymbol
): FirDeserializationContext = FirDeserializationContext(
@@ -25251,6 +25251,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
@@ -0,0 +1,21 @@
// ISSUE: KT-52057
// MODULE: lib
// FILE: Class.kt
annotation class Ann(val p: String)
class Class {
object Obj {
const val Const = "const"
}
}
// MODULE: main(lib)
// FILE: main.kt
import Class
@Ann("${Class.Obj.Const}+")
fun f(): String = "OK"
fun box() = f()
@@ -24771,6 +24771,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
@@ -25251,6 +25251,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
@@ -20808,6 +20808,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/createNestedClass.kt");
@@ -19901,6 +19901,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
@@ -19865,6 +19865,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
@@ -17591,6 +17591,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/createNestedClass.kt");
@@ -22522,6 +22522,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("considerPropertyInitValueFromNestedClass.kt")
public void testConsiderPropertyInitValueFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/innerNested/considerPropertyInitValueFromNestedClass.kt");
}
@Test
@TestMetadata("createNestedClass.kt")
public void testCreateNestedClass() throws Exception {