[FIR2IR] Fix generation of val initialization after smart-cast, again
#KT-57284
This commit is contained in:
committed by
Space Team
parent
f1c673c166
commit
7a6a3a0b1d
+8
-1
@@ -572,7 +572,7 @@ class CallAndReferenceGenerator(
|
||||
// If we found neither a setter nor a backing field, check if we have an override (possibly fake) of a val with
|
||||
// backing field. This can happen in a class initializer where `this` was smart-casted. See KT-57105.
|
||||
if (setter == null && backingField == null) {
|
||||
backingField = irProperty.overriddenSymbols.firstNotNullOfOrNull { it.owner.backingField }
|
||||
backingField = irProperty.overriddenBackingFieldOrNull()
|
||||
}
|
||||
|
||||
when {
|
||||
@@ -624,6 +624,13 @@ class CallAndReferenceGenerator(
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrProperty.overriddenBackingFieldOrNull(): IrField? {
|
||||
return overriddenSymbols.firstNotNullOfOrNull {
|
||||
val owner = it.owner
|
||||
owner.backingField ?: owner.overriddenBackingFieldOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
fun convertToIrConstructorCall(annotation: FirAnnotation): IrExpression {
|
||||
val coneType = annotation.annotationTypeRef.coneTypeSafe<ConeLookupTagBasedType>()
|
||||
?.fullyExpandedType(session) as? ConeLookupTagBasedType
|
||||
|
||||
+15
-2
@@ -7,10 +7,23 @@ open class MessageBusImpl {
|
||||
|
||||
init {
|
||||
this as RootBus
|
||||
parentBus = "OK"
|
||||
parentBus = "O"
|
||||
}
|
||||
}
|
||||
|
||||
class RootBus2: CompositeMessageBus2()
|
||||
|
||||
open class CompositeMessageBus2: MessageBusImpl2()
|
||||
|
||||
open class MessageBusImpl2 {
|
||||
val parentBus: Any?
|
||||
|
||||
init {
|
||||
this as RootBus2
|
||||
parentBus = "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return RootBus().parentBus as String
|
||||
return "" + RootBus().parentBus + RootBus2().parentBus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user