FIR IDE: check backing field with BODY_RESOLVE
This commit is contained in:
committed by
Ilya Kirillov
parent
f4c5f02bfe
commit
cabc47516a
+2
-3
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.idea.frontend.api.symbols
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
|
||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
public sealed class KtVariableLikeSymbol : KtCallableSymbol(), KtNamedSymbol, KtSymbolWithKind {
|
||||
@@ -42,7 +42,7 @@ public abstract class KtBackingFieldSymbol : KtVariableLikeSymbol() {
|
||||
abstract override fun createPointer(): KtSymbolPointer<KtVariableLikeSymbol>
|
||||
|
||||
public companion object {
|
||||
private val fieldName = Name.identifier("field")
|
||||
private val fieldName = StandardNames.BACKING_FIELD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public abstract class KtEnumEntrySymbol : KtVariableLikeSymbol(), KtSymbolWithMe
|
||||
final override val receiverType: KtTypeAndAnnotations? get() = null
|
||||
public abstract val containingEnumClassIdIfNonLocal: ClassId?
|
||||
|
||||
|
||||
abstract override fun createPointer(): KtSymbolPointer<KtEnumEntrySymbol>
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -97,7 +97,8 @@ internal class KtFirKotlinPropertySymbol(
|
||||
property.setter?.let { builder.callableBuilder.buildPropertyAccessorSymbol(it) } as? KtPropertySetterSymbol
|
||||
}
|
||||
|
||||
override val hasBackingField: Boolean get() = firRef.withFir { it.hasBackingField }
|
||||
// NB: `field` in accessors indicates the property should have a backing field. To see that, though, we need BODY_RESOLVE.
|
||||
override val hasBackingField: Boolean get() = firRef.withFir(FirResolvePhase.BODY_RESOLVE) { it.hasBackingField }
|
||||
|
||||
override val isLateInit: Boolean get() = firRef.withFir { it.isLateInit }
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
var p: Int
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
KtFirPropertyGetterSymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: null
|
||||
hasBody: true
|
||||
hasStableParameterNames: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: ACCESSOR
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
|
||||
KtFirValueParameterSymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: value
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
deprecationStatus: null
|
||||
|
||||
KtFirPropertySetterSymbol:
|
||||
annotatedType: [] kotlin/Unit
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: null
|
||||
hasBody: true
|
||||
hasStableParameterNames: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
parameter: KtFirValueParameterSymbol(value)
|
||||
receiverType: null
|
||||
symbolKind: ACCESSOR
|
||||
valueParameters: [
|
||||
KtFirValueParameterSymbol(value)
|
||||
]
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
|
||||
KtFirKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/Int
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /p
|
||||
dispatchType: null
|
||||
getter: KtFirPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: true
|
||||
hasGetter: true
|
||||
hasSetter: true
|
||||
initializer: null
|
||||
isConst: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: false
|
||||
modality: FINAL
|
||||
name: p
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: KtFirPropertySetterSymbol(<setter>)
|
||||
symbolKind: TOP_LEVEL
|
||||
visibility: Public
|
||||
deprecationStatus: null
|
||||
getterDeprecationStatus: null
|
||||
javaGetterName: getP
|
||||
javaSetterName: setP
|
||||
setterDeprecationStatus: null
|
||||
+6
@@ -36,6 +36,12 @@ public class SymbolByPsiTestGenerated extends AbstractSymbolByPsiTest {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/anonymousObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("backingField.kt")
|
||||
public void testBackingField() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/backingField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("class.kt")
|
||||
public void testClass() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user