[FIR] ensure that status is resolved when we create fake overrides
We should create the fake override only when we already have resolved status. Otherwise, the fake override declaration will be created with unresolved status, and its status will never be computed as we do not resolve fake override declarations. ^KT-56543
This commit is contained in:
committed by
Space Team
parent
7c8f7bdbfb
commit
cc52e896f9
+15
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -112,6 +112,8 @@ object FirFakeOverrideGenerator {
|
||||
newVisibility: Visibility? = null,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution? = null
|
||||
): FirSimpleFunction {
|
||||
checkStatusIsResolved(baseFunction)
|
||||
|
||||
return buildSimpleFunction {
|
||||
source = baseFunction.source
|
||||
moduleData = session.nullableModuleData ?: baseFunction.moduleData
|
||||
@@ -147,6 +149,8 @@ object FirFakeOverrideGenerator {
|
||||
isExpect: Boolean,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution?
|
||||
): FirConstructor {
|
||||
checkStatusIsResolved(baseConstructor)
|
||||
|
||||
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
||||
// As second alternative, we can invent some light-weight kind of FirRegularClass
|
||||
return buildConstructor {
|
||||
@@ -350,6 +354,8 @@ object FirFakeOverrideGenerator {
|
||||
newVisibility: Visibility? = null,
|
||||
fakeOverrideSubstitution: FakeOverrideSubstitution? = null
|
||||
): FirProperty {
|
||||
checkStatusIsResolved(baseProperty)
|
||||
|
||||
return buildProperty {
|
||||
source = baseProperty.source
|
||||
moduleData = session.moduleData
|
||||
@@ -724,4 +730,12 @@ object FirFakeOverrideGenerator {
|
||||
class Value<out A>(val value: A) : Maybe<A>()
|
||||
object Nothing : Maybe<kotlin.Nothing>()
|
||||
}
|
||||
|
||||
private fun checkStatusIsResolved(member: FirCallableDeclaration) {
|
||||
check(member.status is FirResolvedDeclarationStatus) {
|
||||
"Status should be resolved for a declaration to create it fake override, " +
|
||||
"otherwise the status of the fake override will never be resolved." +
|
||||
"The status was unresolved for ${member::class.java.simpleName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user