[FIR2IR] Include generated IR fields into Fir2IrCommonMemberStorage

In case of HMPP structure with common JVM module (e.g. shared between
  JVM and Android) one can reference the same field from java code,
  so it should be shared between fir2ir sessions

^KT-63574 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-12-07 14:06:59 +02:00
committed by Space Team
parent 701a48b211
commit 58678c09e8
11 changed files with 73 additions and 1 deletions
@@ -35211,6 +35211,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -35211,6 +35211,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -41,6 +41,8 @@ class Fir2IrCommonMemberStorage(
val constructorCache: ConcurrentHashMap<FirConstructor, IrConstructorSymbol> = ConcurrentHashMap()
val fieldCache: ConcurrentHashMap<FirField, IrFieldSymbol> = ConcurrentHashMap()
val propertyCache: ConcurrentHashMap<FirProperty, IrPropertySymbol> = ConcurrentHashMap()
val getterForPropertyCache: ConcurrentHashMap<IrSymbol, IrSimpleFunctionSymbol> = ConcurrentHashMap()
val setterForPropertyCache: ConcurrentHashMap<IrSymbol, IrSimpleFunctionSymbol> = ConcurrentHashMap()
@@ -166,7 +166,7 @@ class Fir2IrDeclarationStorage(
private val delegatedReverseCache: ConcurrentHashMap<IrSymbol, FirDeclaration> = ConcurrentHashMap()
private val fieldCache: ConcurrentHashMap<FirField, IrFieldSymbol> = ConcurrentHashMap()
private val fieldCache: ConcurrentHashMap<FirField, IrFieldSymbol> = commonMemberStorage.fieldCache
private data class FieldStaticOverrideKey(val lookupTag: ConeClassLikeLookupTag, val name: Name)
@@ -34792,6 +34792,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -34792,6 +34792,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -34792,6 +34792,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM_IR
// LANGUAGE: +MultiPlatformProjects
// FULL_JDK
// ISSUE: KT-63574
// MODULE: commonJvm
// FILE: common.kt
import java.nio.ByteOrder
fun foo(): String = ByteOrder.LITTLE_ENDIAN.toString()
// MODULE: platformJvm()()(commonJvm)
// FILE: platform.kt
import java.nio.ByteOrder
fun bar(): String = ByteOrder.LITTLE_ENDIAN.toString()
fun box(): String {
val expected = "LITTLE_ENDIAN"
if (foo() != expected) return "Fail 1"
if (bar() != expected) return "Fail 2"
return "OK"
}
@@ -34792,6 +34792,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -34792,6 +34792,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@Test
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@Nested
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@@ -29667,6 +29667,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/multiplatform/k2/jvmDeclarationsUpdatedMembersInCommonModule.kt");
}
@TestMetadata("staticjavaFieldInCommonCode.kt")
public void testStaticjavaFieldInCommonCode() throws Exception {
runTest("compiler/testData/codegen/box/multiplatform/k2/staticjavaFieldInCommonCode.kt");
}
@TestMetadata("compiler/testData/codegen/box/multiplatform/k2/annotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)