JVM_IR: fix deserialization of Java static field symbols

This commit is contained in:
Georgy Bronnikov
2021-06-24 14:01:46 +03:00
committed by TeamCityServer
parent 955ee07517
commit fa4efd3303
10 changed files with 52 additions and 6 deletions
@@ -4118,6 +4118,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn
runTest("compiler/testData/codegen/boxInline/simple/funImportedFromObject.kt");
}
@Test
@TestMetadata("importedJavaStaticField.kt")
public void testImportedJavaStaticField() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/importedJavaStaticField.kt");
}
@Test
@TestMetadata("inlineCallInInlineLambda.kt")
public void testInlineCallInInlineLambda() throws Exception {
@@ -117,8 +117,8 @@ class DescriptorByIdSignatureFinder(
if (isConstructorName(current)) addAll(classDescriptor.constructors)
addAll(memberScope.getContributedFunctions(current, NoLookupLocation.FROM_BACKEND))
addAll(memberScope.getContributedVariables(current, NoLookupLocation.FROM_BACKEND))
addAll(classDescriptor.staticScope.getContributedDescriptors { it == current })
}
addAll(classDescriptor.staticScope.getContributedDescriptors().filter { it.name == current })
}
}
}
@@ -443,7 +443,7 @@ class IrBodyDeserializer(
val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null
val superQualifier = if (access.hasSuper()) {
declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol
declarationDeserializer.deserializeIrSymbolAndRemap(access.`super`) as IrClassSymbol
} else null
val receiver = if (access.hasReceiver()) {
deserializeExpression(access.receiver)
@@ -549,7 +549,7 @@ class IrBodyDeserializer(
val access = proto.fieldAccess
val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrFieldSymbol
val superQualifier = if (access.hasSuper()) {
declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol
declarationDeserializer.deserializeIrSymbolAndRemap(access.`super`) as IrClassSymbol
} else null
val receiver = if (access.hasReceiver()) {
deserializeExpression(access.receiver)
@@ -361,7 +361,9 @@ open class IrFileSerializer(
is IrReturnableBlockSymbol ->
BinarySymbolData.SymbolKind.RETURNABLE_BLOCK_SYMBOL
is IrFieldSymbol ->
if (symbol.owner.correspondingPropertySymbol?.owner.let { it == null || it.isDelegated })
if (symbol.owner.correspondingPropertySymbol?.owner.let {
it == null || it.isDelegated || it.getter == null && it.setter == null
})
BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL
else
BinarySymbolData.SymbolKind.FIELD_SYMBOL
@@ -164,7 +164,8 @@ private fun referencePublicSymbol(
BinarySymbolData.SymbolKind.CLASS_SYMBOL -> referenceClass(descriptor as ClassDescriptor)
BinarySymbolData.SymbolKind.CONSTRUCTOR_SYMBOL -> referenceConstructor(descriptor as ClassConstructorDescriptor)
BinarySymbolData.SymbolKind.ENUM_ENTRY_SYMBOL -> referenceEnumEntry(descriptor as ClassDescriptor)
BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL -> referenceField(descriptor as PropertyDescriptor)
BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL, BinarySymbolData.SymbolKind.FIELD_SYMBOL
-> referenceField(descriptor as PropertyDescriptor)
BinarySymbolData.SymbolKind.FUNCTION_SYMBOL -> referenceSimpleFunction(descriptor as FunctionDescriptor)
BinarySymbolData.SymbolKind.TYPEALIAS_SYMBOL -> referenceTypeAlias(descriptor as TypeAliasDescriptor)
BinarySymbolData.SymbolKind.PROPERTY_SYMBOL -> referenceProperty(descriptor as PropertyDescriptor)
@@ -175,7 +176,8 @@ private fun referencePublicSymbol(
BinarySymbolData.SymbolKind.CLASS_SYMBOL -> referenceClassFromLinker(idSig)
BinarySymbolData.SymbolKind.CONSTRUCTOR_SYMBOL -> referenceConstructorFromLinker(idSig)
BinarySymbolData.SymbolKind.ENUM_ENTRY_SYMBOL -> referenceEnumEntryFromLinker(idSig)
BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL -> referenceFieldFromLinker(idSig)
BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL, BinarySymbolData.SymbolKind.FIELD_SYMBOL
-> referenceFieldFromLinker(idSig)
BinarySymbolData.SymbolKind.FUNCTION_SYMBOL -> referenceSimpleFunctionFromLinker(idSig)
BinarySymbolData.SymbolKind.TYPEALIAS_SYMBOL -> referenceTypeAliasFromLinker(idSig)
BinarySymbolData.SymbolKind.PROPERTY_SYMBOL -> referencePropertyFromLinker(idSig)
@@ -0,0 +1,12 @@
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FILE: 1.kt
import java.util.Locale
inline fun inlineFun(): String {
val root = Locale.ROOT
return "OK"
}
// FILE: 2.kt
fun box() = inlineFun()
@@ -4118,6 +4118,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
runTest("compiler/testData/codegen/boxInline/simple/funImportedFromObject.kt");
}
@Test
@TestMetadata("importedJavaStaticField.kt")
public void testImportedJavaStaticField() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/importedJavaStaticField.kt");
}
@Test
@TestMetadata("inlineCallInInlineLambda.kt")
public void testInlineCallInInlineLambda() throws Exception {
@@ -4118,6 +4118,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
runTest("compiler/testData/codegen/boxInline/simple/funImportedFromObject.kt");
}
@Test
@TestMetadata("importedJavaStaticField.kt")
public void testImportedJavaStaticField() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/importedJavaStaticField.kt");
}
@Test
@TestMetadata("inlineCallInInlineLambda.kt")
public void testInlineCallInInlineLambda() throws Exception {
@@ -4016,6 +4016,12 @@ public class IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends Ab
runTest("compiler/testData/codegen/boxInline/simple/funImportedFromObject.kt");
}
@Test
@TestMetadata("importedJavaStaticField.kt")
public void testImportedJavaStaticField() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/importedJavaStaticField.kt");
}
@Test
@TestMetadata("inlineCallInInlineLambda.kt")
public void testInlineCallInInlineLambda() throws Exception {
@@ -4118,6 +4118,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO
runTest("compiler/testData/codegen/boxInline/simple/funImportedFromObject.kt");
}
@Test
@TestMetadata("importedJavaStaticField.kt")
public void testImportedJavaStaticField() throws Exception {
runTest("compiler/testData/codegen/boxInline/simple/importedJavaStaticField.kt");
}
@Test
@TestMetadata("inlineCallInInlineLambda.kt")
public void testInlineCallInInlineLambda() throws Exception {