FIR IDE: fix scope processing for enum entry with members
This commit is contained in:
committed by
Ilya Kirillov
parent
748a2d2e7c
commit
d4e1ecd9d3
+3
-3
@@ -7,10 +7,10 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticPropertiesScope
|
||||
import org.jetbrains.kotlin.fir.resolve.scope
|
||||
@@ -63,8 +63,8 @@ internal class KtFirScopeProvider(
|
||||
is KtFirAnonymousObjectSymbol -> firRef.withFir(FirResolvePhase.TYPES, body)
|
||||
is KtFirEnumEntrySymbol -> firRef.withFir(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||
val initializer = it.initializer
|
||||
check(initializer is FirAnonymousObject)
|
||||
body(initializer)
|
||||
check(initializer is FirAnonymousObjectExpression) { "Unexpected enum entry initializer: ${initializer?.javaClass}" }
|
||||
body(initializer.anonymousObject)
|
||||
}
|
||||
else -> error { "Unknown KtSymbolWithDeclarations implementation ${this::class.qualifiedName}" }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
enum class Style(val value: String) {
|
||||
SHEET("foo") {
|
||||
override val exitAnimation: String
|
||||
get() = "bar"
|
||||
};
|
||||
|
||||
abstract val exitAnimation: String
|
||||
}
|
||||
|
||||
// RESULT
|
||||
/*
|
||||
KtFirValueParameterSymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: value
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
|
||||
KtFirConstructorSymbol:
|
||||
annotatedType: [] Style
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
containingClassIdIfNonLocal: Style
|
||||
dispatchType: null
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
isPrimary: true
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: [KtFirValueParameterSymbol(value)]
|
||||
visibility: Private
|
||||
|
||||
KtFirPropertyGetterSymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: null
|
||||
hasBody: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: ACCESSOR
|
||||
visibility: Public
|
||||
|
||||
KtFirKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: <anonymous>
|
||||
getter: KtFirPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: false
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isExtension: false
|
||||
isLateInit: false
|
||||
isOverride: true
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: FINAL
|
||||
name: exitAnimation
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: MEMBER
|
||||
visibility: Public
|
||||
|
||||
KtFirEnumEntrySymbol:
|
||||
annotatedType: [] Style
|
||||
callableIdIfNonLocal: /Style.SHEET
|
||||
containingEnumClassIdIfNonLocal: Style
|
||||
isExtension: false
|
||||
name: SHEET
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: MEMBER
|
||||
|
||||
KtFirKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /Style.exitAnimation
|
||||
dispatchType: Style
|
||||
getter: KtFirPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: false
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isExtension: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: ABSTRACT
|
||||
name: exitAnimation
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: MEMBER
|
||||
visibility: Public
|
||||
|
||||
KtFirNamedClassOrObjectSymbol:
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
classIdIfNonLocal: Style
|
||||
classKind: ENUM_CLASS
|
||||
companionObject: null
|
||||
isData: false
|
||||
isExternal: false
|
||||
isFun: false
|
||||
isInline: false
|
||||
isInner: false
|
||||
modality: FINAL
|
||||
name: Style
|
||||
origin: SOURCE
|
||||
superTypes: [[] kotlin/Enum<Style>]
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
*/
|
||||
@@ -0,0 +1,125 @@
|
||||
KtFirValueParameterSymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isVararg: false
|
||||
name: value
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: LOCAL
|
||||
|
||||
KtFirConstructorSymbol:
|
||||
annotatedType: [] Style
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
containingClassIdIfNonLocal: Style
|
||||
dispatchType: null
|
||||
hasStableParameterNames: true
|
||||
isExtension: false
|
||||
isPrimary: true
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: [KtFirValueParameterSymbol(value)]
|
||||
visibility: Private
|
||||
|
||||
KtFirPropertyGetterSymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: null
|
||||
hasBody: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: ACCESSOR
|
||||
visibility: Public
|
||||
|
||||
KtFirKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: null
|
||||
dispatchType: <anonymous>
|
||||
getter: KtFirPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: false
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isExtension: false
|
||||
isLateInit: false
|
||||
isOverride: true
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: FINAL
|
||||
name: exitAnimation
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: MEMBER
|
||||
visibility: Public
|
||||
|
||||
KtFirEnumEntrySymbol:
|
||||
annotatedType: [] Style
|
||||
callableIdIfNonLocal: /Style.SHEET
|
||||
containingEnumClassIdIfNonLocal: Style
|
||||
isExtension: false
|
||||
name: SHEET
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
symbolKind: MEMBER
|
||||
|
||||
KtFirKotlinPropertySymbol:
|
||||
annotatedType: [] kotlin/String
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
callableIdIfNonLocal: /Style.exitAnimation
|
||||
dispatchType: Style
|
||||
getter: KtFirPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: false
|
||||
hasGetter: true
|
||||
hasSetter: false
|
||||
initializer: null
|
||||
isConst: false
|
||||
isExtension: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: true
|
||||
modality: ABSTRACT
|
||||
name: exitAnimation
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
setter: null
|
||||
symbolKind: MEMBER
|
||||
visibility: Public
|
||||
|
||||
KtFirNamedClassOrObjectSymbol:
|
||||
annotationClassIds: []
|
||||
annotations: []
|
||||
classIdIfNonLocal: Style
|
||||
classKind: ENUM_CLASS
|
||||
companionObject: null
|
||||
isData: false
|
||||
isExternal: false
|
||||
isFun: false
|
||||
isInline: false
|
||||
isInner: false
|
||||
modality: FINAL
|
||||
name: Style
|
||||
origin: SOURCE
|
||||
superTypes: [[] kotlin/Enum<Style>]
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
+6
@@ -72,6 +72,12 @@ public class SymbolByPsiTestGenerated extends AbstractSymbolByPsiTest {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/enum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumValueMember.kt")
|
||||
public void testEnumValueMember() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/symbols/symbolByPsi/enumValueMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user