[FIR] Properly support @JvmRecord

^KT-53867 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-09-19 14:52:39 +03:00
parent c0ad67c4f9
commit 6623456d2a
23 changed files with 490 additions and 29 deletions
@@ -26,9 +26,15 @@ private fun FirAnnotation.toAnnotationLookupTag(): ConeClassLikeLookupTag? =
// this cast fails when we have generic-typed annotations @T
(annotationTypeRef.coneType as? ConeClassLikeType)?.lookupTag
private fun FirAnnotation.toAnnotationLookupTagSafe(): ConeClassLikeLookupTag? =
annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.lookupTag
fun FirAnnotation.toAnnotationClassId(): ClassId? =
toAnnotationLookupTag()?.classId
fun FirAnnotation.toAnnotationClassIdSafe(): ClassId? =
toAnnotationLookupTagSafe()?.classId
private fun FirAnnotation.toAnnotationClass(session: FirSession): FirRegularClass? =
toAnnotationLookupTag()?.toSymbol(session)?.fir as? FirRegularClass
@@ -99,6 +105,10 @@ fun FirDeclaration.hasAnnotation(classId: ClassId): Boolean {
return annotations.hasAnnotation(classId)
}
fun FirDeclaration.hasAnnotationSafe(classId: ClassId): Boolean {
return annotations.hasAnnotationSafe(classId)
}
fun FirBasedSymbol<*>.hasAnnotation(classId: ClassId): Boolean {
return resolvedAnnotationsWithClassIds.hasAnnotation(classId)
}
@@ -107,6 +117,10 @@ fun List<FirAnnotation>.hasAnnotation(classId: ClassId): Boolean {
return this.any { it.toAnnotationClassId() == classId }
}
fun List<FirAnnotation>.hasAnnotationSafe(classId: ClassId): Boolean {
return this.any { it.toAnnotationClassIdSafe() == classId }
}
fun <D> FirBasedSymbol<out D>.getAnnotationByClassId(classId: ClassId): FirAnnotation? where D : FirAnnotationContainer, D : FirDeclaration {
return fir.getAnnotationByClassId(classId)
}