[AA] introduce FirReceiverParameter

^KT-54417
This commit is contained in:
Dmitrii Gridin
2022-10-18 08:56:10 +02:00
committed by Space Team
parent be7d282974
commit 37d688ae83
21 changed files with 139 additions and 24 deletions
@@ -1,11 +1,12 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.symbols
import org.jetbrains.kotlin.KtSourceElement
import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
@@ -42,22 +43,28 @@ abstract class FirBasedSymbol<E : FirDeclaration> {
get() = fir.annotations
val resolvedAnnotationsWithArguments: List<FirAnnotation>
get() {
lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
return fir.annotations
}
get() = fir.resolvedAnnotationsWithArguments(this)
val resolvedAnnotationsWithClassIds: List<FirAnnotation>
get() {
lazyResolveToPhase(FirResolvePhase.TYPES)
return fir.annotations
}
get() = fir.resolvedAnnotationsWithClassIds(this)
val resolvedAnnotationClassIds: List<ClassId>
get() {
lazyResolveToPhase(FirResolvePhase.TYPES)
return fir.annotations.mapNotNull { (it.annotationTypeRef.coneType as? ConeClassLikeType)?.lookupTag?.classId }
}
get() = fir.resolvedAnnotationClassIds(this)
}
fun FirAnnotationContainer.resolvedAnnotationsWithArguments(anchorElement: FirBasedSymbol<*>): List<FirAnnotation> {
anchorElement.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
return annotations
}
fun FirAnnotationContainer.resolvedAnnotationsWithClassIds(anchorElement: FirBasedSymbol<*>): List<FirAnnotation> {
anchorElement.lazyResolveToPhase(FirResolvePhase.TYPES)
return annotations
}
fun FirAnnotationContainer.resolvedAnnotationClassIds(anchorElement: FirBasedSymbol<*>): List<ClassId> {
anchorElement.lazyResolveToPhase(FirResolvePhase.TYPES)
return annotations.mapNotNull { (it.annotationTypeRef.coneType as? ConeClassLikeType)?.lookupTag?.classId }
}
@RequiresOptIn
@@ -1,11 +1,12 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.symbols.impl
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
@@ -32,6 +33,12 @@ abstract class FirCallableSymbol<D : FirCallableDeclaration> : FirBasedSymbol<D>
return fir.receiverParameter?.type as FirResolvedTypeRef?
}
val receiverParameter: FirAnnotationContainer?
get() {
ensureType(fir.receiverParameter?.type)
return fir.receiverParameter
}
val resolvedContextReceivers: List<FirContextReceiver>
get() {
lazyResolveToPhase(FirResolvePhase.TYPES)