[FIR2IR] Generate IR for f/o of common classes generated during platform conversion
This change fixes tests which were muted in one of previous commits
This commit is contained in:
committed by
Space Team
parent
65797e8fba
commit
c9ff0c41fc
@@ -116,6 +116,12 @@ class Fir2IrConverter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (components.session.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) {
|
||||||
|
// See the comment to generateUnboundFakeOverrides function itself
|
||||||
|
@OptIn(LeakedDeclarationCaches::class)
|
||||||
|
declarationStorage.generateUnboundFakeOverrides()
|
||||||
|
}
|
||||||
|
|
||||||
evaluateConstants(irModuleFragment, components)
|
evaluateConstants(irModuleFragment, components)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1141,6 +1141,61 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------ binding unbound symbols ------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function iterates over all f/o symbols created in declaration storage and binds all unbound symbols
|
||||||
|
*
|
||||||
|
* Usually all symbols are bound after fir2ir conversion is over, but there is a case in MPP scenario when some fake-override
|
||||||
|
* for common classes appears only during conversion of platform session:
|
||||||
|
*
|
||||||
|
* // MODULE: common
|
||||||
|
* expect interface A
|
||||||
|
*
|
||||||
|
* interface B : A {
|
||||||
|
* // f/o fun foo() // (1)
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // MODULE: platform()()(common)
|
||||||
|
* actual interface A {
|
||||||
|
* fun foo() // (2)
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* fun test(b: B) {
|
||||||
|
* b.foo() // (3)
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Here during common module conversion there is no `foo` function in scope of class B, so (1) is not generated
|
||||||
|
* During conversion of function test we reference symbol for (1) at line (3), so this symbol is created. But
|
||||||
|
* there is no code which generate actual IR for this symbol, because IR for f/o is generated only during
|
||||||
|
* conversion of corresponing class (and `B` is already converted)
|
||||||
|
*
|
||||||
|
* So to fix this issue we need to call this method after conversion of platform module
|
||||||
|
*/
|
||||||
|
@LeakedDeclarationCaches
|
||||||
|
internal fun generateUnboundFakeOverrides() {
|
||||||
|
for ((identifier, symbol) in irForFirSessionDependantDeclarationMap) {
|
||||||
|
if (symbol.isBound) continue
|
||||||
|
val (originalSymbol, dispatchReceiverLookupTag, _) = identifier
|
||||||
|
val irParent = findIrParent(originalSymbol.fir, dispatchReceiverLookupTag)
|
||||||
|
when (originalSymbol) {
|
||||||
|
is FirPropertySymbol -> createAndCacheIrProperty(
|
||||||
|
originalSymbol.fir,
|
||||||
|
irParent,
|
||||||
|
fakeOverrideOwnerLookupTag = dispatchReceiverLookupTag
|
||||||
|
)
|
||||||
|
|
||||||
|
is FirNamedFunctionSymbol -> createAndCacheIrFunction(
|
||||||
|
originalSymbol.fir,
|
||||||
|
irParent,
|
||||||
|
fakeOverrideOwnerLookupTag = dispatchReceiverLookupTag
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> error("Unexpected declaration: $originalSymbol")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------ scripts ------------------------------------
|
// ------------------------------------ scripts ------------------------------------
|
||||||
|
|
||||||
fun getCachedIrScript(script: FirScript): IrScript? {
|
fun getCachedIrScript(script: FirScript): IrScript? {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// !LANGUAGE: +MultiPlatformProjects
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
||||||
// IGNORE_BACKEND_K2: JVM_IR
|
|
||||||
// Ignore reason: (TODO) how should generate IR for common f/o after actualization?
|
|
||||||
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// MODULE: common
|
// MODULE: common
|
||||||
// TARGET_PLATFORM: Common
|
// TARGET_PLATFORM: Common
|
||||||
|
|||||||
-3
@@ -3,9 +3,6 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// !LANGUAGE: +MultiPlatformProjects
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
||||||
// IGNORE_BACKEND_K2: JVM_IR
|
|
||||||
// Ignore reason: (TODO) how should generate IR for common f/o after actualization?
|
|
||||||
|
|
||||||
// MODULE: common
|
// MODULE: common
|
||||||
// TARGET_PLATFORM: Common
|
// TARGET_PLATFORM: Common
|
||||||
// FILE: common.kt
|
// FILE: common.kt
|
||||||
|
|||||||
-2
@@ -3,8 +3,6 @@
|
|||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
// IGNORE_CODEGEN_WITH_IR_FAKE_OVERRIDE_GENERATION: KT-62535
|
||||||
// !LANGUAGE: +MultiPlatformProjects
|
// !LANGUAGE: +MultiPlatformProjects
|
||||||
// IGNORE_BACKEND_K2: JVM_IR
|
|
||||||
// Ignore reason: (TODO) how should generate IR for common f/o after actualization?
|
|
||||||
|
|
||||||
// MODULE: common
|
// MODULE: common
|
||||||
// TARGET_PLATFORM: Common
|
// TARGET_PLATFORM: Common
|
||||||
|
|||||||
Reference in New Issue
Block a user