FIR2IR: fix f/o & delegate overridden symbol generation #KT-52745 Fixed
This commit is contained in:
+4
-9
@@ -194,6 +194,10 @@ class DelegatedMemberGenerator(
|
||||
declaration.overriddenSymbols = basePropertySymbols[declaration]?.flatMap {
|
||||
fakeOverrideGenerator.getOverriddenSymbolsInSupertypes(it, superClasses)
|
||||
}?.filter { it.owner != declaration }.orEmpty()
|
||||
declaration.getter!!.overriddenSymbols = declaration.overriddenSymbols.mapNotNull { it.owner.getter?.symbol }
|
||||
if (declaration.isVar) {
|
||||
declaration.setter!!.overriddenSymbols = declaration.overriddenSymbols.mapNotNull { it.owner.setter?.symbol }
|
||||
}
|
||||
}
|
||||
else -> continue
|
||||
}
|
||||
@@ -301,18 +305,9 @@ class DelegatedMemberGenerator(
|
||||
annotationGenerator.generate(delegateProperty, firDelegateProperty)
|
||||
|
||||
val getter = delegateProperty.getter!!
|
||||
getter.overriddenSymbols =
|
||||
firDelegateProperty.generateOverriddenAccessorSymbols(
|
||||
firSubClass,
|
||||
isGetter = true
|
||||
)
|
||||
annotationGenerator.generate(getter, firDelegateProperty)
|
||||
if (delegateProperty.isVar) {
|
||||
val setter = delegateProperty.setter!!
|
||||
setter.overriddenSymbols =
|
||||
firDelegateProperty.generateOverriddenAccessorSymbols(
|
||||
firSubClass, isGetter = false
|
||||
)
|
||||
annotationGenerator.generate(setter, firDelegateProperty)
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -391,13 +391,13 @@ class FakeOverrideGenerator(
|
||||
declarationStorage.classifierStorage.getIrClassSymbol(overriddenContainingClass.symbol).owner as? IrClass
|
||||
?: return emptyList()
|
||||
|
||||
return if (overriddenContainingIrClass in superClasses) {
|
||||
// `overridden` was a FIR declaration in some of the supertypes
|
||||
listOf(irProducer(overridden))
|
||||
} else {
|
||||
// There were no FIR declaration in supertypes, but we know that we have fake overrides in some of them
|
||||
superClasses.mapNotNull {
|
||||
declarationStorage.getFakeOverrideInClass(it, overridden.fir)?.let { fakeOverrideInClass ->
|
||||
return superClasses.mapNotNull { superClass ->
|
||||
if (superClass == overriddenContainingIrClass) {
|
||||
// `overridden` was a FIR declaration in some of the supertypes
|
||||
irProducer(overridden)
|
||||
} else {
|
||||
// There were no FIR declaration in supertypes, but we know that we have fake overrides in some of them
|
||||
declarationStorage.getFakeOverrideInClass(superClass, overridden.fir)?.let { fakeOverrideInClass ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
irProducer(fakeOverrideInClass.symbol as F)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
sealed class A : CharSequence {
|
||||
|
||||
@@ -16,6 +16,7 @@ FILE fqName:<root> fileName:/delegationInSealed.kt
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public [data] superTypes:[<root>.A; kotlin.CharSequence]'
|
||||
FUN DELEGATED_MEMBER name:get visibility:public modality:OPEN <> ($this:<root>.A.B, index:kotlin.Int) returnType:kotlin.Char [operator]
|
||||
overridden:
|
||||
public abstract fun get (index: kotlin.Int): kotlin.Char [fake_override,operator] declared in <root>.A
|
||||
public abstract fun get (index: kotlin.Int): kotlin.Char [operator] declared in kotlin.CharSequence
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A.B
|
||||
VALUE_PARAMETER name:index index:0 type:kotlin.Int
|
||||
@@ -27,6 +28,7 @@ FILE fqName:<root> fileName:/delegationInSealed.kt
|
||||
index: GET_VAR 'index: kotlin.Int declared in <root>.A.B.get' type=kotlin.Int origin=null
|
||||
FUN DELEGATED_MEMBER name:subSequence visibility:public modality:OPEN <> ($this:<root>.A.B, startIndex:kotlin.Int, endIndex:kotlin.Int) returnType:kotlin.CharSequence
|
||||
overridden:
|
||||
public abstract fun subSequence (startIndex: kotlin.Int, endIndex: kotlin.Int): kotlin.CharSequence [fake_override] declared in <root>.A
|
||||
public abstract fun subSequence (startIndex: kotlin.Int, endIndex: kotlin.Int): kotlin.CharSequence declared in kotlin.CharSequence
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A.B
|
||||
VALUE_PARAMETER name:startIndex index:0 type:kotlin.Int
|
||||
@@ -40,10 +42,12 @@ FILE fqName:<root> fileName:/delegationInSealed.kt
|
||||
endIndex: GET_VAR 'endIndex: kotlin.Int declared in <root>.A.B.subSequence' type=kotlin.Int origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:length visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public abstract length: kotlin.Int [fake_override,val]
|
||||
public abstract length: kotlin.Int [val]
|
||||
FUN DELEGATED_MEMBER name:<get-length> visibility:public modality:OPEN <> ($this:<root>.A.B) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:length visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public abstract fun <get-length> (): kotlin.Int [fake_override] declared in <root>.A
|
||||
public abstract fun <get-length> (): kotlin.Int declared in kotlin.CharSequence
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.A.B
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -92,6 +92,7 @@ FILE fqName:<root> fileName:/SignatureClash.kt
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DataClass modality:FINAL visibility:public [data] superTypes:[<root>.Derived; <root>.Delegate]'
|
||||
FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:<root>.DataClass) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun bar (): kotlin.Unit [fake_override] declared in <root>.Derived
|
||||
public abstract fun bar (): kotlin.Unit declared in <root>.Delegate
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.DataClass
|
||||
BLOCK_BODY
|
||||
|
||||
Reference in New Issue
Block a user