Split property use-site targets during FIR building

This commit is contained in:
Mikhail Glukhikh
2021-10-06 15:36:52 +03:00
committed by teamcityserver
parent 2a9a1dbb86
commit 7243d30869
26 changed files with 227 additions and 138 deletions
@@ -180,6 +180,9 @@ sealed class FirFakeSourceElementKind : FirSourceElementKind() {
// for the implicit field storing the delegated object for class delegation
// with a fake source that refers to the KtExpression that creates the delegate
object ClassDelegationField : FirFakeSourceElementKind()
// for annotation moved to another element due to annotation use-site target
object FromUseSiteTarget : FirFakeSourceElementKind()
}
sealed class FirSourceElement {
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.builder.buildDefaultSetterValueParameter
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
import org.jetbrains.kotlin.fir.expressions.FirBlock
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
@@ -72,12 +73,16 @@ abstract class FirDefaultPropertyAccessor(
propertyTypeRef: FirTypeRef,
visibility: Visibility,
propertySymbol: FirPropertySymbol,
isGetter: Boolean
isGetter: Boolean,
parameterAnnotations: List<FirAnnotation> = emptyList(),
): FirDefaultPropertyAccessor {
return if (isGetter) {
FirDefaultPropertyGetter(source, moduleData, origin, propertyTypeRef, visibility, propertySymbol, Modality.FINAL)
} else {
FirDefaultPropertySetter(source, moduleData, origin, propertyTypeRef, visibility, propertySymbol, Modality.FINAL)
FirDefaultPropertySetter(
source, moduleData, origin, propertyTypeRef, visibility, propertySymbol, Modality.FINAL,
parameterAnnotations = parameterAnnotations
)
}
}
}
@@ -116,7 +121,8 @@ class FirDefaultPropertySetter(
propertySymbol: FirPropertySymbol,
modality: Modality = Modality.FINAL,
effectiveVisibility: EffectiveVisibility? = null,
symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol()
symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol(),
parameterAnnotations: List<FirAnnotation> = emptyList(),
) : FirDefaultPropertyAccessor(
source,
moduleData,
@@ -129,6 +135,7 @@ class FirDefaultPropertySetter(
this@builder.origin = origin
this@builder.returnTypeRef = propertyTypeRef
this@builder.symbol = FirValueParameterSymbol(Name.special("<default-setter-parameter>"))
this@builder.annotations += parameterAnnotations
}
),
propertySymbol,