FIR: fix position and reporting of PRIVATE_SETTER_*

Previously `FirPropertyAccessor.source` references the `KtProperty` if
the user code contains a setter or getter that doesn't contain a body.
For example, with the following

```
val i: Int = 1
  private set
```

The `FirPropertyAccessor` would reference the `KtProperty` as the
source.

This change makes `FirPropertyAccessor` reference `KtPropertyAccessor`
as the source if possible, regardless of whether the body is present or
not.
This commit is contained in:
Tianyu Geng
2021-02-18 16:28:27 -08:00
committed by Mikhail Glukhikh
parent bdeecfc188
commit 5bdea9652b
14 changed files with 56 additions and 55 deletions
@@ -653,11 +653,11 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = AbstractPropertyWithSetter::class
}
abstract class PrivateSetterForAbstractProperty : KtFirDiagnostic<PsiElement>() {
abstract class PrivateSetterForAbstractProperty : KtFirDiagnostic<KtModifierListOwner>() {
override val diagnosticClass get() = PrivateSetterForAbstractProperty::class
}
abstract class PrivateSetterForOpenProperty : KtFirDiagnostic<PsiElement>() {
abstract class PrivateSetterForOpenProperty : KtFirDiagnostic<KtModifierListOwner>() {
override val diagnosticClass get() = PrivateSetterForOpenProperty::class
}
@@ -1056,14 +1056,14 @@ internal class AbstractPropertyWithSetterImpl(
internal class PrivateSetterForAbstractPropertyImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.PrivateSetterForAbstractProperty(), KtAbstractFirDiagnostic<PsiElement> {
) : KtFirDiagnostic.PrivateSetterForAbstractProperty(), KtAbstractFirDiagnostic<KtModifierListOwner> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class PrivateSetterForOpenPropertyImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.PrivateSetterForOpenProperty(), KtAbstractFirDiagnostic<PsiElement> {
) : KtFirDiagnostic.PrivateSetterForOpenProperty(), KtAbstractFirDiagnostic<KtModifierListOwner> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}