FIR2IR: implement early f/o overridden symbols binding #KT-42784 Fixed
Related to KT-49288
This commit is contained in:
committed by
teamcity
parent
5b6e21690b
commit
0622a47493
@@ -57,6 +57,7 @@ class Fir2IrConverter(
|
||||
val irClass = registerClassAndNestedClasses(regularClass, parent)
|
||||
processClassAndNestedClassHeaders(regularClass)
|
||||
processClassMembers(regularClass, irClass)
|
||||
bindFakeOverridesInClass(irClass)
|
||||
}
|
||||
|
||||
fun processRegisteredLocalClassAndNestedClasses(regularClass: FirRegularClass, irClass: IrClass) {
|
||||
@@ -205,6 +206,25 @@ class Fir2IrConverter(
|
||||
return irClass
|
||||
}
|
||||
|
||||
fun bindFakeOverridesInFile(file: FirFile) {
|
||||
val irFile = declarationStorage.getIrFile(file)
|
||||
for (irDeclaration in irFile.declarations) {
|
||||
if (irDeclaration is IrClass) {
|
||||
bindFakeOverridesInClass(irDeclaration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bindFakeOverridesInClass(klass: IrClass) {
|
||||
fakeOverrideGenerator.bindOverriddenSymbols(klass.declarations)
|
||||
delegatedMemberGenerator.bindDelegatedMembersOverriddenSymbols(klass)
|
||||
for (irDeclaration in klass.declarations) {
|
||||
if (irDeclaration is IrClass) {
|
||||
bindFakeOverridesInClass(irDeclaration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun delegatedMembers(irClass: IrClass): List<FirDeclaration> {
|
||||
return irClass.declarations.filter {
|
||||
it.origin == IrDeclarationOrigin.DELEGATED_MEMBER
|
||||
@@ -379,6 +399,9 @@ class Fir2IrConverter(
|
||||
for (firFile in allFirFiles) {
|
||||
converter.processFileAndClassMembers(firFile)
|
||||
}
|
||||
for (firFile in allFirFiles) {
|
||||
converter.bindFakeOverridesInFile(firFile)
|
||||
}
|
||||
|
||||
for (firFile in allFirFiles) {
|
||||
firFile.accept(fir2irVisitor, null)
|
||||
|
||||
@@ -116,6 +116,7 @@ class Fir2IrVisitor(
|
||||
classifierStorage.putEnumEntryClassInScope(enumEntry, correspondingClass)
|
||||
val anonymousObject = (enumEntry.initializer as FirAnonymousObjectExpression).anonymousObject
|
||||
converter.processAnonymousObjectMembers(anonymousObject, correspondingClass)
|
||||
converter.bindFakeOverridesInClass(correspondingClass)
|
||||
conversionScope.withParent(correspondingClass) {
|
||||
conversionScope.withContainingFirClass(anonymousObject) {
|
||||
memberGenerator.convertClassContent(correspondingClass, anonymousObject)
|
||||
@@ -180,6 +181,7 @@ class Fir2IrVisitor(
|
||||
val irAnonymousObject = classifierStorage.getCachedIrClass(anonymousObject)?.apply { this.parent = irParent }
|
||||
?: classifierStorage.createIrAnonymousObject(anonymousObject, irParent = irParent)
|
||||
converter.processAnonymousObjectMembers(anonymousObject, irAnonymousObject)
|
||||
converter.bindFakeOverridesInClass(irAnonymousObject)
|
||||
conversionScope.withParent(irAnonymousObject) {
|
||||
conversionScope.withContainingFirClass(anonymousObject) {
|
||||
memberGenerator.convertClassContent(irAnonymousObject, anonymousObject)
|
||||
|
||||
-2
@@ -68,8 +68,6 @@ internal class ClassMemberGenerator(
|
||||
convertFunctionContent(irPrimaryConstructor, primaryConstructor, containingClass = klass)
|
||||
}
|
||||
}
|
||||
fakeOverrideGenerator.bindOverriddenSymbols(irClass.declarations)
|
||||
components.delegatedMemberGenerator.bindDelegatedMembersOverriddenSymbols(irClass)
|
||||
|
||||
allDeclarations.forEach { declaration ->
|
||||
when {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FILE: test.kt
|
||||
|
||||
fun box(): String {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// FILE: test.kt
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ FILE fqName:<root> fileName:/smartCastOnFakeOverrideReceiver.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.B
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.A.testA1' type=kotlin.Any origin=null
|
||||
then: CALL 'public final fun f (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=null
|
||||
then: CALL 'public final fun f (): kotlin.Int [fake_override] declared in <root>.B' type=kotlin.Int origin=null
|
||||
$this: TYPE_OP type=<root>.B origin=IMPLICIT_CAST typeOperand=<root>.B
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.A.testA1' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
@@ -45,7 +45,7 @@ FILE fqName:<root> fileName:/smartCastOnFakeOverrideReceiver.kt
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.B
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.A.testA2' type=kotlin.Any origin=null
|
||||
then: CALL 'public final fun <get-aVal> (): kotlin.Int declared in <root>.A' type=kotlin.Int origin=GET_PROPERTY
|
||||
then: CALL 'public final fun <get-aVal> (): kotlin.Int [fake_override] declared in <root>.B' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: TYPE_OP type=<root>.B origin=IMPLICIT_CAST typeOperand=<root>.B
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.A.testA2' type=kotlin.Any origin=null
|
||||
BRANCH
|
||||
|
||||
Reference in New Issue
Block a user