[FIR2IR] Allow to get cached symbols in fake override generator
This commit is contained in:
+12
-2
@@ -79,7 +79,15 @@ class FakeOverrideGenerator(
|
|||||||
(functionSymbol.callableId.classId == klass.symbol.classId || fakeOverrideMode == FakeOverrideMode.SUBSTITUTION)
|
(functionSymbol.callableId.classId == klass.symbol.classId || fakeOverrideMode == FakeOverrideMode.SUBSTITUTION)
|
||||||
) {
|
) {
|
||||||
// Substitution case
|
// Substitution case
|
||||||
val irFunction = declarationStorage.createIrFunction(
|
// NB: we can get same substituted FIR fake override in a different class, if it derives the same genetic type
|
||||||
|
// open class Base<T> {
|
||||||
|
// fun foo(): T
|
||||||
|
// }
|
||||||
|
// class Derived1 : Base<String>() {}
|
||||||
|
// class Derived2 : Base<String>() {}
|
||||||
|
// That's why we must check parent during caching...
|
||||||
|
val irFunction = declarationStorage.getCachedIrFunction(originalFunction)?.takeIf { it.parent == this }
|
||||||
|
?: declarationStorage.createIrFunction(
|
||||||
originalFunction, irParent = this,
|
originalFunction, irParent = this,
|
||||||
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
||||||
origin = origin
|
origin = origin
|
||||||
@@ -127,7 +135,9 @@ class FakeOverrideGenerator(
|
|||||||
(propertySymbol.callableId.classId == klass.symbol.classId || fakeOverrideMode == FakeOverrideMode.SUBSTITUTION)
|
(propertySymbol.callableId.classId == klass.symbol.classId || fakeOverrideMode == FakeOverrideMode.SUBSTITUTION)
|
||||||
) {
|
) {
|
||||||
// Substitution case
|
// Substitution case
|
||||||
val irProperty = declarationStorage.createIrProperty(
|
// NB: see comment above about substituted function' parent
|
||||||
|
val irProperty = declarationStorage.getCachedIrProperty(originalProperty)?.takeIf { it.parent == this}
|
||||||
|
?: declarationStorage.createIrProperty(
|
||||||
originalProperty, irParent = this,
|
originalProperty, irParent = this,
|
||||||
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
||||||
origin = origin
|
origin = origin
|
||||||
|
|||||||
Reference in New Issue
Block a user