[LL FIR] calculate lazy bodies for type annotations

^KT-56543
This commit is contained in:
Dmitrii Gridin
2023-03-29 13:38:19 +02:00
committed by Space Team
parent badd09e4fd
commit 77e1bc6f9e
5 changed files with 15 additions and 4 deletions
@@ -18,12 +18,17 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirLazyDelegatedConstructorCall
import org.jetbrains.kotlin.fir.extensions.registeredPluginAnnotations
import org.jetbrains.kotlin.fir.resolve.transformers.plugin.CompilerRequiredAnnotationsHelper
import org.jetbrains.kotlin.fir.scopes.kotlinScopeProvider
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.FirUserTypeRef
import org.jetbrains.kotlin.fir.types.coneType
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.fir.visitors.transformSingle
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.SinceKotlin
import org.jetbrains.kotlin.fir.types.customAnnotations
import org.jetbrains.kotlin.fir.types.forEachType
internal object FirLazyBodiesCalculator {
fun calculateLazyBodiesInside(designation: FirDesignation) {
@@ -223,6 +228,16 @@ private object FirLazyAnnotationTransformer : FirTransformer<FirLazyAnnotationTr
return element
}
override fun transformResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: FirLazyAnnotationTransformerData): FirTypeRef {
resolvedTypeRef.coneType.forEachType { coneType ->
for (typeArgumentAnnotation in coneType.customAnnotations) {
typeArgumentAnnotation.accept(this, data)
}
}
return super.transformResolvedTypeRef(resolvedTypeRef, data)
}
override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: FirLazyAnnotationTransformerData): FirStatement {
val shouldCalculate = data.compilerAnnotationsOnly == FirLazyAnnotationTransformerScope.ALL_ANNOTATIONS ||
canBeCompilerAnnotation(annotationCall, data.session)
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
annotation class Ann
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
annotation class Ann
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
class A
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_VARIABLE, -UNUSED_PARAMETER
class A