[Fir2IR] Get rid of simple symbol table usages
We have two sources of truth in Fir2Ir - declaration storages, which maps fir to ir symbols and symbolTable which maps IdSignature to ir symbol. The long-term goal is to have only one - declaration storages. This commit goes to this goal by removing all symbolTable usages that are straightforward to remove, i.e., all except: 1. classes as there is some code, that uses signature inside ClassSymbol 2. functions/properties as sometimes declaration storage fails to match symbols correctly (i.e. for generated data class members) 3. type parameters, as we need to remove functions first. As a side effect, it fixes some of the signature clash cases on valid code, as we no longer rely on signature uniqueness, except cases mentioned above. ^KT-65274 Fixed ^KT-64990
This commit is contained in:
committed by
Space Team
parent
06684f207a
commit
1cc138431d
+6
@@ -19352,6 +19352,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -19352,6 +19352,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ internal fun IrDeclarationParent.declareThisReceiverParameter(
|
|||||||
explicitReceiver: FirReceiverParameter? = null,
|
explicitReceiver: FirReceiverParameter? = null,
|
||||||
isAssignable: Boolean = false
|
isAssignable: Boolean = false
|
||||||
): IrValueParameter {
|
): IrValueParameter {
|
||||||
return symbolTable.irFactory.createValueParameter(
|
return irFactory.createValueParameter(
|
||||||
startOffset = startOffset,
|
startOffset = startOffset,
|
||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
origin = thisOrigin,
|
origin = thisOrigin,
|
||||||
|
|||||||
+3
-19
@@ -358,7 +358,7 @@ class Fir2IrClassifierStorage(
|
|||||||
} else {
|
} else {
|
||||||
irParent.origin
|
irParent.origin
|
||||||
}
|
}
|
||||||
val symbol = createEnumEntrySymbol(enumEntry)
|
val symbol = IrEnumEntrySymbolImpl()
|
||||||
return classifiersGenerator.createIrEnumEntry(
|
return classifiersGenerator.createIrEnumEntry(
|
||||||
enumEntry,
|
enumEntry,
|
||||||
irParent = irParent,
|
irParent = irParent,
|
||||||
@@ -369,34 +369,18 @@ class Fir2IrClassifierStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createEnumEntrySymbol(enumEntry: FirEnumEntry): IrEnumEntrySymbol {
|
|
||||||
val signature = signatureComposer.composeSignature(enumEntry)
|
|
||||||
return when {
|
|
||||||
signature != null -> symbolTable.referenceEnumEntry(signature)
|
|
||||||
else -> IrEnumEntrySymbolImpl()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------ typealiases ------------------------------------
|
// ------------------------------------ typealiases ------------------------------------
|
||||||
|
|
||||||
fun createAndCacheIrTypeAlias(
|
fun createAndCacheIrTypeAlias(
|
||||||
typeAlias: FirTypeAlias,
|
typeAlias: FirTypeAlias,
|
||||||
parent: IrDeclarationParent
|
parent: IrDeclarationParent
|
||||||
): IrTypeAlias {
|
): IrTypeAlias {
|
||||||
val symbol = createTypeAliasSymbol(typeAlias)
|
val symbol = IrTypeAliasSymbolImpl()
|
||||||
return classifiersGenerator.createIrTypeAlias(typeAlias, parent, symbol).also {
|
return classifiersGenerator.createIrTypeAlias(typeAlias, parent, symbol).also {
|
||||||
typeAliasCache[typeAlias] = it
|
typeAliasCache[typeAlias] = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTypeAliasSymbol(typeAlias: FirTypeAlias): IrTypeAliasSymbol {
|
|
||||||
val signature = signatureComposer.composeSignature(typeAlias)
|
|
||||||
return when {
|
|
||||||
signature != null -> symbolTable.referenceTypeAlias(signature)
|
|
||||||
else -> IrTypeAliasSymbolImpl()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun getCachedTypeAlias(firTypeAlias: FirTypeAlias): IrTypeAlias? = typeAliasCache[firTypeAlias]
|
internal fun getCachedTypeAlias(firTypeAlias: FirTypeAlias): IrTypeAlias? = typeAliasCache[firTypeAlias]
|
||||||
|
|
||||||
fun referenceTypeAlias(firTypeAliasSymbol: FirTypeAliasSymbol): IrTypeAlias {
|
fun referenceTypeAlias(firTypeAliasSymbol: FirTypeAliasSymbol): IrTypeAlias {
|
||||||
@@ -413,7 +397,7 @@ class Fir2IrClassifierStorage(
|
|||||||
firTypeAlias.origin
|
firTypeAlias.origin
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
val symbol = createTypeAliasSymbol(firTypeAlias)
|
val symbol = IrTypeAliasSymbolImpl()
|
||||||
val irTypeAlias = lazyDeclarationsGenerator.createIrLazyTypeAlias(firTypeAlias, irParent, symbol)
|
val irTypeAlias = lazyDeclarationsGenerator.createIrLazyTypeAlias(firTypeAlias, irParent, symbol)
|
||||||
typeAliasCache[firTypeAlias] = irTypeAlias
|
typeAliasCache[firTypeAlias] = irTypeAlias
|
||||||
irTypeAlias.prepareTypeParameters()
|
irTypeAlias.prepareTypeParameters()
|
||||||
|
|||||||
+5
-16
@@ -598,7 +598,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val backingFieldSymbol = runIf(property.delegate != null || property.hasBackingField) {
|
val backingFieldSymbol = runIf(property.delegate != null || property.hasBackingField) {
|
||||||
createFieldSymbol(signature = null)
|
createFieldSymbol()
|
||||||
}
|
}
|
||||||
|
|
||||||
return PropertySymbols(propertySymbol, getterSymbol, setterSymbol, backingFieldSymbol)
|
return PropertySymbols(propertySymbol, getterSymbol, setterSymbol, backingFieldSymbol)
|
||||||
@@ -888,8 +888,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
||||||
): IrField {
|
): IrField {
|
||||||
val containingClassLookupTag = (irParent as IrClass?)?.classId?.toLookupTag()
|
val containingClassLookupTag = (irParent as IrClass?)?.classId?.toLookupTag()
|
||||||
val signature = signatureComposer.composeSignature(field, containingClassLookupTag)
|
val symbol = createFieldSymbol()
|
||||||
val symbol = createFieldSymbol(signature)
|
|
||||||
|
|
||||||
val irField = callablesGenerator.createIrField(field, irParent, symbol, type, origin)
|
val irField = callablesGenerator.createIrField(field, irParent, symbol, type, origin)
|
||||||
|
|
||||||
@@ -902,11 +901,8 @@ class Fir2IrDeclarationStorage(
|
|||||||
return irField
|
return irField
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createFieldSymbol(signature: IdSignature?): IrFieldSymbol {
|
private fun createFieldSymbol(): IrFieldSymbol {
|
||||||
return when {
|
return IrFieldSymbolImpl()
|
||||||
signature != null -> symbolTable.referenceField(signature)
|
|
||||||
else -> IrFieldSymbolImpl()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function returns null if this field/ownerClassId combination does not describe static fake override
|
// This function returns null if this field/ownerClassId combination does not describe static fake override
|
||||||
@@ -1374,19 +1370,12 @@ class Fir2IrDeclarationStorage(
|
|||||||
|
|
||||||
fun createIrScript(script: FirScript): IrScript {
|
fun createIrScript(script: FirScript): IrScript {
|
||||||
getCachedIrScript(script)?.let { error("IrScript already created: ${script.render()}") }
|
getCachedIrScript(script)?.let { error("IrScript already created: ${script.render()}") }
|
||||||
val symbol = createScriptSymbol(signatureComposer.composeSignature(script))
|
val symbol = IrScriptSymbolImpl()
|
||||||
return callablesGenerator.createIrScript(script, symbol).also {
|
return callablesGenerator.createIrScript(script, symbol).also {
|
||||||
scriptCache[script] = it
|
scriptCache[script] = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createScriptSymbol(signature: IdSignature?): IrScriptSymbol {
|
|
||||||
return when {
|
|
||||||
signature != null -> symbolTable.referenceScript(signature)
|
|
||||||
else -> IrScriptSymbolImpl()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------ scoping ------------------------------------
|
// ------------------------------------ scoping ------------------------------------
|
||||||
|
|
||||||
fun enterScope(symbol: IrSymbol) {
|
fun enterScope(symbol: IrSymbol) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class IrBuiltInsOverFir(
|
|||||||
private val symbolProvider: FirSymbolProvider
|
private val symbolProvider: FirSymbolProvider
|
||||||
get() = session.symbolProvider
|
get() = session.symbolProvider
|
||||||
|
|
||||||
override val irFactory: IrFactory = components.symbolTable.irFactory
|
override val irFactory: IrFactory = components.irFactory
|
||||||
|
|
||||||
private val kotlinPackage = StandardClassIds.BASE_KOTLIN_PACKAGE
|
private val kotlinPackage = StandardClassIds.BASE_KOTLIN_PACKAGE
|
||||||
|
|
||||||
|
|||||||
+6
@@ -19341,6 +19341,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -19341,6 +19341,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -19341,6 +19341,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// FILE: a/A.java
|
||||||
|
package a;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
static final String X = "Fail";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: B.java
|
||||||
|
public class B extends a.A {
|
||||||
|
private final String X = "OK";
|
||||||
|
|
||||||
|
public String get() { return X; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: box.kt
|
||||||
|
class C : B()
|
||||||
|
|
||||||
|
fun box(): String = C().get()
|
||||||
+6
@@ -19341,6 +19341,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -18489,6 +18489,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt49371.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt49371.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -19341,6 +19341,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+6
@@ -19341,6 +19341,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
|
|||||||
+5
@@ -16114,6 +16114,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65116.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt65274.kt")
|
||||||
|
public void testKt65274() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fakeOverride/kt65274.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("methodOfAnyFromInterface.kt")
|
@TestMetadata("methodOfAnyFromInterface.kt")
|
||||||
public void testMethodOfAnyFromInterface() throws Exception {
|
public void testMethodOfAnyFromInterface() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fakeOverride/methodOfAnyFromInterface.kt");
|
runTest("compiler/testData/codegen/box/fakeOverride/methodOfAnyFromInterface.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user