[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)
|
||||
) {
|
||||
// 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,
|
||||
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
||||
origin = origin
|
||||
@@ -127,7 +135,9 @@ class FakeOverrideGenerator(
|
||||
(propertySymbol.callableId.classId == klass.symbol.classId || fakeOverrideMode == FakeOverrideMode.SUBSTITUTION)
|
||||
) {
|
||||
// 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,
|
||||
thisReceiverOwner = declarationStorage.findIrParent(baseSymbol.fir) as? IrClass,
|
||||
origin = origin
|
||||
|
||||
Reference in New Issue
Block a user