[FIR] preserve real source for property accessors

^ KT-59705
If property is delegated, it can't have property accessors with non-default impl,
but it can contain property accessors declarations
with non-default visibility, annotations, etc.
Seems, it's more logical to preserve them as fake sources
than use property itself
This commit is contained in:
Anna Kozlova
2023-06-28 15:10:46 +02:00
parent 3279313f2c
commit 600b5ec6e5
6 changed files with 255 additions and 3 deletions
@@ -417,8 +417,9 @@ fun <T> FirPropertyBuilder.generateAccessorsByDelegate(
val annotations = getter?.annotations
val returnTarget = FirFunctionTarget(null, isLambda = false)
val getterStatus = getter?.status
val getterElement = getter?.source?.fakeElement(KtFakeSourceElementKind.DelegatedPropertyAccessor) ?: fakeSource
getter = buildPropertyAccessor {
this.source = fakeSource
this.source = getterElement
this.moduleData = moduleData
origin = FirDeclarationOrigin.Source
returnTypeRef = FirImplicitTypeRefImplWithoutSource
@@ -456,8 +457,9 @@ fun <T> FirPropertyBuilder.generateAccessorsByDelegate(
val annotations = setter?.annotations
val parameterAnnotations = setter?.valueParameters?.firstOrNull()?.annotations
val setterStatus = setter?.status
val setterElement = setter?.source?.fakeElement(KtFakeSourceElementKind.DelegatedPropertyAccessor) ?: fakeSource
setter = buildPropertyAccessor {
this.source = fakeSource
this.source = setterElement
this.moduleData = moduleData
origin = FirDeclarationOrigin.Source
returnTypeRef = moduleData.session.builtinTypes.unitType