FIR: create argument mapping for annotation call in general

This commit is contained in:
Jinseong Jeon
2020-07-12 23:24:30 -07:00
committed by Mikhail Glukhikh
parent 1a861b2df9
commit 4e6bd33eca
2 changed files with 18 additions and 15 deletions
@@ -464,13 +464,18 @@ private fun FirQualifiedAccess.expressionTypeOrUnitForAssignment(): ConeKotlinTy
fun FirAnnotationCall.getCorrespondingConstructorReferenceOrNull(session: FirSession): FirResolvedNamedReference? = fun FirAnnotationCall.getCorrespondingConstructorReferenceOrNull(session: FirSession): FirResolvedNamedReference? =
annotationTypeRef.coneType.classId?.let { annotationTypeRef.coneType.classId?.let {
(session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir if (it.isLocal) {
?.getPrimaryConstructorIfAny() // TODO: How to retrieve local annotaiton's constructor?
?.let { annotationConstructor -> null
buildResolvedNamedReference { } else {
source = this@getCorrespondingConstructorReferenceOrNull.source (session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir
name = it.shortClassName ?.getPrimaryConstructorIfAny()
resolvedSymbol = annotationConstructor.symbol ?.let { annotationConstructor ->
buildResolvedNamedReference {
source = this@getCorrespondingConstructorReferenceOrNull.source
name = it.shortClassName
resolvedSymbol = annotationConstructor.symbol
}
} }
} }
} }
@@ -691,13 +691,11 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
(annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also { (annotationCall.transformChildren(transformer, data) as FirAnnotationCall).also {
// TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls // TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls
it.argumentList.transformArguments(integerLiteralTypeApproximator, null) it.argumentList.transformArguments(integerLiteralTypeApproximator, null)
if (it.arguments.any { arg -> arg is FirNamedArgumentExpression }) { annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference ->
annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference -> val argumentMapping =
val argumentMapping = mapArguments(it.arguments, calleeReference.resolvedSymbol.fir as FirFunction<*>)
mapArguments(it.arguments, calleeReference.resolvedSymbol.fir as FirFunction<*>) .toArgumentToParameterMapping()
.toArgumentToParameterMapping() it.replaceArgumentList(buildResolvedArgumentList(argumentMapping))
it.replaceArgumentList(buildResolvedArgumentList(argumentMapping))
}
} }
it.replaceResolveStatus(status) it.replaceResolveStatus(status)
dataFlowAnalyzer.exitAnnotationCall(it) dataFlowAnalyzer.exitAnnotationCall(it)