[FIR] set correct resolve phase for default getter, setter and backing field

^KT-58163 Fixed
This commit is contained in:
Dmitrii Gridin
2023-04-21 14:51:49 +02:00
committed by Space Team
parent 1703d3a47e
commit 866e8a26c7
5 changed files with 31 additions and 15 deletions
@@ -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.
*/
@@ -265,7 +265,8 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
visibility,
propertySymbol,
propertyModality,
effectiveVisibility
effectiveVisibility,
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES,
)
}.apply {
replaceAnnotations(
@@ -324,7 +325,8 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
visibility,
propertySymbol,
propertyModality,
effectiveVisibility
effectiveVisibility,
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES,
)
}.apply {
replaceAnnotations(
@@ -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.
*/
@@ -93,18 +93,23 @@ public class PropertyBuildingContext(
isVar = !isVal
getter = FirDefaultPropertyGetter(
source = null, session.moduleData, key.origin, returnTypeRef, status.visibility, symbol,
Modality.FINAL, resolvedStatus.effectiveVisibility
Modality.FINAL, resolvedStatus.effectiveVisibility,
resolvePhase = FirResolvePhase.BODY_RESOLVE,
)
if (isVar) {
setter = FirDefaultPropertySetter(
source = null, session.moduleData, key.origin, returnTypeRef, setterVisibility ?: status.visibility,
symbol, Modality.FINAL, resolvedStatus.effectiveVisibility
symbol, Modality.FINAL, resolvedStatus.effectiveVisibility,
resolvePhase = FirResolvePhase.BODY_RESOLVE,
)
} else {
require(setterVisibility == null) { "isVar = false but setterVisibility is specified. Did you forget to set isVar = true?" }
}
if (hasBackingField) {
backingField = FirDefaultPropertyBackingField(session.moduleData, mutableListOf(), returnTypeRef, isVar, symbol, status)
backingField = FirDefaultPropertyBackingField(
session.moduleData, mutableListOf(), returnTypeRef, isVar, symbol, status,
resolvePhase = FirResolvePhase.BODY_RESOLVE,
)
}
isLocal = false
bodyResolveState = FirPropertyBodyResolveState.EVERYTHING_RESOLVED
@@ -443,6 +443,7 @@ object FirFakeOverrideGenerator {
propertySymbol = propertySymbol,
modality = modality ?: Modality.FINAL,
effectiveVisibility = effectiveVisibility,
resolvePhase = resolvePhase,
).apply {
replaceAnnotations(annotations)
}
@@ -455,6 +456,7 @@ object FirFakeOverrideGenerator {
propertySymbol = propertySymbol,
modality = modality ?: Modality.FINAL,
effectiveVisibility = effectiveVisibility,
resolvePhase = resolvePhase,
).apply {
replaceAnnotations(annotations)
}
@@ -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.
*/
@@ -39,10 +39,11 @@ abstract class FirDefaultPropertyAccessor(
visibility: Visibility,
modality: Modality = Modality.FINAL,
effectiveVisibility: EffectiveVisibility? = null,
symbol: FirPropertyAccessorSymbol
symbol: FirPropertyAccessorSymbol,
resolvePhase: FirResolvePhase,
) : FirPropertyAccessorImpl(
source,
resolvePhase = FirResolvePhase.RAW_FIR,
resolvePhase,
moduleData,
origin,
FirDeclarationAttributes(),
@@ -103,7 +104,8 @@ class FirDefaultPropertyGetter(
propertySymbol: FirPropertySymbol,
modality: Modality = Modality.FINAL,
effectiveVisibility: EffectiveVisibility? = null,
symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol()
symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol(),
resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR,
) : FirDefaultPropertyAccessor(
source,
moduleData,
@@ -115,7 +117,8 @@ class FirDefaultPropertyGetter(
visibility = visibility,
modality = modality,
effectiveVisibility = effectiveVisibility,
symbol = symbol
symbol = symbol,
resolvePhase = resolvePhase,
)
class FirDefaultPropertySetter(
@@ -129,6 +132,7 @@ class FirDefaultPropertySetter(
effectiveVisibility: EffectiveVisibility? = null,
propertyAccessorSymbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol(),
parameterAnnotations: List<FirAnnotation> = emptyList(),
resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR,
) : FirDefaultPropertyAccessor(
source,
moduleData,
@@ -136,6 +140,7 @@ class FirDefaultPropertySetter(
FirImplicitUnitTypeRef(source),
valueParameters = mutableListOf(
buildDefaultSetterValueParameter builder@{
this@builder.resolvePhase = resolvePhase
this@builder.source = source?.fakeElement(KtFakeSourceElementKind.DefaultAccessor)
this@builder.containingFunctionSymbol = propertyAccessorSymbol
this@builder.moduleData = moduleData
@@ -150,5 +155,6 @@ class FirDefaultPropertySetter(
visibility = visibility,
modality = modality,
effectiveVisibility = effectiveVisibility,
symbol = propertyAccessorSymbol
symbol = propertyAccessorSymbol,
resolvePhase = resolvePhase,
)
@@ -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.
*/
@@ -25,10 +25,11 @@ class FirDefaultPropertyBackingField(
isVar: Boolean,
propertySymbol: FirPropertySymbol,
status: FirDeclarationStatus,
resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR,
) : FirBackingFieldImpl(
source = null,
moduleData = moduleData,
resolvePhase = FirResolvePhase.RAW_FIR,
resolvePhase = resolvePhase,
origin = FirDeclarationOrigin.Synthetic,
attributes = FirDeclarationAttributes(),
returnTypeRef = returnTypeRef,