[FIR] Don't resolve annotations twice

This commit is contained in:
Dmitriy Novozhilov
2020-03-30 11:47:34 +03:00
parent 28738971bc
commit 1177a56815
5 changed files with 13 additions and 0 deletions
@@ -563,10 +563,12 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
}
override fun transformAnnotationCall(annotationCall: FirAnnotationCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
if (annotationCall.resolved) return annotationCall.compose()
dataFlowAnalyzer.enterAnnotationCall(annotationCall)
return (annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also {
// TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls
it.argumentList.transformArguments(integerLiteralTypeApproximator, null)
it.replaceResolved(true)
dataFlowAnalyzer.exitAnnotationCall(it)
}.compose()
}
@@ -22,8 +22,11 @@ abstract class FirAnnotationCall : FirExpression(), FirCall {
abstract override val argumentList: FirArgumentList
abstract val useSiteTarget: AnnotationUseSiteTarget?
abstract val annotationTypeRef: FirTypeRef
abstract val resolved: Boolean
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnnotationCall(this, data)
abstract fun replaceResolved(newResolved: Boolean)
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirAnnotationCall
}
@@ -25,6 +25,7 @@ internal class FirAnnotationCallImpl(
override var annotationTypeRef: FirTypeRef,
) : FirAnnotationCall() {
override val typeRef: FirTypeRef get() = annotationTypeRef
override var resolved: Boolean = false
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -49,4 +50,8 @@ internal class FirAnnotationCallImpl(
override fun replaceArgumentList(newArgumentList: FirArgumentList) {
argumentList = newArgumentList
}
override fun replaceResolved(newResolved: Boolean) {
resolved = newResolved
}
}
@@ -78,6 +78,8 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
value = "annotationTypeRef"
withGetter = true
}
defaultFalse("resolved")
}
impl(arrayOfCall)
@@ -398,6 +398,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
annotationCall.configure {
+field("useSiteTarget", annotationUseSiteTargetType, nullable = true)
+field("annotationTypeRef", typeRef)
+booleanField("resolved", withReplace = true)
}
arraySetCall.configure {