FIR2IR: discard fake overrides for property accessors according to base visibility
This commit is contained in:
committed by
Mikhail Glukhikh
parent
6985c5fd2a
commit
1e3019798a
+14
-9
@@ -144,6 +144,7 @@ class FakeOverrideGenerator(
|
|||||||
)
|
)
|
||||||
irProperty.parent = this
|
irProperty.parent = this
|
||||||
result += irProperty.withProperty {
|
result += irProperty.withProperty {
|
||||||
|
discardAccessorsAccordingToBaseVisibility(baseSymbol)
|
||||||
setOverriddenSymbolsForAccessors(declarationStorage, originalProperty, firOverriddenSymbol = baseSymbol)
|
setOverriddenSymbolsForAccessors(declarationStorage, originalProperty, firOverriddenSymbol = baseSymbol)
|
||||||
}
|
}
|
||||||
} else if (fakeOverrideMode != FakeOverrideMode.SUBSTITUTION && originalProperty.allowsToHaveFakeOverrideIn(klass)) {
|
} else if (fakeOverrideMode != FakeOverrideMode.SUBSTITUTION && originalProperty.allowsToHaveFakeOverrideIn(klass)) {
|
||||||
@@ -160,15 +161,7 @@ class FakeOverrideGenerator(
|
|||||||
fakeOverrideProperty, irParent = this,
|
fakeOverrideProperty, irParent = this,
|
||||||
thisReceiverOwner = declarationStorage.findIrParent(originalProperty) as? IrClass,
|
thisReceiverOwner = declarationStorage.findIrParent(originalProperty) as? IrClass,
|
||||||
origin = origin
|
origin = origin
|
||||||
).apply {
|
)
|
||||||
// Do not create fake overrides for accessors if not allowed to do so, e.g., private lateinit var.
|
|
||||||
if (baseSymbol.fir.getter?.allowsToHaveFakeOverride != true) {
|
|
||||||
getter = null
|
|
||||||
}
|
|
||||||
if (baseSymbol.fir.setter?.allowsToHaveFakeOverride != true) {
|
|
||||||
setter = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (irProperty.backingField?.type?.containsErrorType() == true ||
|
if (irProperty.backingField?.type?.containsErrorType() == true ||
|
||||||
irProperty.getter?.returnType?.containsErrorType() == true
|
irProperty.getter?.returnType?.containsErrorType() == true
|
||||||
) {
|
) {
|
||||||
@@ -176,6 +169,7 @@ class FakeOverrideGenerator(
|
|||||||
}
|
}
|
||||||
irProperty.parent = this
|
irProperty.parent = this
|
||||||
result += irProperty.withProperty {
|
result += irProperty.withProperty {
|
||||||
|
discardAccessorsAccordingToBaseVisibility(baseSymbol)
|
||||||
setOverriddenSymbolsForAccessors(declarationStorage, fakeOverrideProperty, firOverriddenSymbol = baseSymbol)
|
setOverriddenSymbolsForAccessors(declarationStorage, fakeOverrideProperty, firOverriddenSymbol = baseSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,6 +179,17 @@ class FakeOverrideGenerator(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrProperty.discardAccessorsAccordingToBaseVisibility(baseSymbol: FirPropertySymbol) {
|
||||||
|
// Do not create fake overrides for accessors if not allowed to do so, e.g., private lateinit var.
|
||||||
|
if (baseSymbol.fir.getter?.allowsToHaveFakeOverride != true) {
|
||||||
|
getter = null
|
||||||
|
}
|
||||||
|
// or private setter
|
||||||
|
if (baseSymbol.fir.setter?.allowsToHaveFakeOverride != true) {
|
||||||
|
setter = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun IrProperty.setOverriddenSymbolsForAccessors(
|
private fun IrProperty.setOverriddenSymbolsForAccessors(
|
||||||
declarationStorage: Fir2IrDeclarationStorage,
|
declarationStorage: Fir2IrDeclarationStorage,
|
||||||
property: FirProperty,
|
property: FirProperty,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
|
|
||||||
package test2
|
package test2
|
||||||
|
|||||||
Reference in New Issue
Block a user