[K2 AA] add hack to fix symbolKind for local class

^KT-54311
^KT-54390
This commit is contained in:
Dmitrii Gridin
2022-10-11 10:45:10 +02:00
committed by Space Team
parent f7568cef5c
commit b15cf05e59
3 changed files with 9 additions and 271 deletions
@@ -27,8 +27,10 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.fir.declarations.FirClass
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.resolve.getContainingDeclaration
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
@@ -44,7 +46,7 @@ internal class KtFirNamedClassOrObjectSymbol(
override val name: Name get() = withValidityAssertion { firSymbol.name }
override val classIdIfNonLocal: ClassId?
get() = withValidityAssertion { firSymbol.classId.takeUnless { it.isLocal } }
get() = withValidityAssertion { firSymbol.getClassIdIfNonLocal() }
/* FirRegularClass modality is not modified by STATUS, so it can be taken from RAW */
override val modality: Modality
@@ -102,6 +104,11 @@ internal class KtFirNamedClassOrObjectSymbol(
override val symbolKind: KtSymbolKind
get() = withValidityAssertion {
when {
// TODO: hack should be dropped after KT-54390
firSymbol.isLocal && (firSymbol.fir.getContainingDeclaration(firResolveSession.useSiteFirSession) as? FirClass)?.let { clazz ->
clazz.declarations.none { it === firSymbol.fir }
} == true -> KtSymbolKind.LOCAL
firSymbol.classId.isNestedClass -> KtSymbolKind.CLASS_MEMBER
firSymbol.isLocal -> KtSymbolKind.LOCAL
else -> KtSymbolKind.TOP_LEVEL
@@ -1,269 +0,0 @@
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T1
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: X.Y
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: true
modality: FINAL
name: Y
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(T1)
]
visibility: Public
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T2
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: X.Z
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: false
modality: FINAL
name: Z
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(T2)
]
visibility: Public
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T3
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T4
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T5
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: null
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: true
modality: FINAL
name: K
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(T5)
]
visibility: Local
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtTypeParameterSymbol:
annotationsList: []
isReified: false
name: T6
origin: SOURCE
typeParameters: []
upperBounds: [
kotlin/Any?
]
variance: INVARIANT
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: null
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: false
modality: FINAL
name: C
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(T6)
]
visibility: Local
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: null
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: false
modality: FINAL
name: U
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: LOCAL
typeParameters: [
KtTypeParameterSymbol(T4)
]
visibility: Local
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /X.foo
contextReceivers: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: foo
origin: SOURCE
receiverType: null
returnType: kotlin/Unit
symbolKind: CLASS_MEMBER
typeParameters: [
KtTypeParameterSymbol(T3)
]
valueParameters: []
visibility: Public
getDispatchReceiver(): X<T>
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtNamedClassOrObjectSymbol:
annotationsList: []
classIdIfNonLocal: X
classKind: CLASS
companionObject: null
contextReceivers: []
isData: false
isExternal: false
isFun: false
isInline: false
isInner: false
modality: FINAL
name: X
origin: SOURCE
superTypes: [
kotlin/Any
]
symbolKind: TOP_LEVEL
typeParameters: [
KtTypeParameterSymbol(T)
]
visibility: Public
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
@@ -206,7 +206,7 @@ KtNamedClassOrObjectSymbol:
superTypes: [
kotlin/Any
]
symbolKind: CLASS_MEMBER
symbolKind: LOCAL
typeParameters: [
KtTypeParameterSymbol(T4)
]