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? =
annotationTypeRef.coneType.classId?.let {
(session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir
?.getPrimaryConstructorIfAny()
?.let { annotationConstructor ->
buildResolvedNamedReference {
source = this@getCorrespondingConstructorReferenceOrNull.source
name = it.shortClassName
resolvedSymbol = annotationConstructor.symbol
if (it.isLocal) {
// TODO: How to retrieve local annotaiton's constructor?
null
} else {
(session.firSymbolProvider.getClassLikeSymbolByFqName(it) as? FirRegularClassSymbol)?.fir
?.getPrimaryConstructorIfAny()
?.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 {
// TODO: it's temporary incorrect solution until we design resolve and completion for annotation calls
it.argumentList.transformArguments(integerLiteralTypeApproximator, null)
if (it.arguments.any { arg -> arg is FirNamedArgumentExpression }) {
annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference ->
val argumentMapping =
mapArguments(it.arguments, calleeReference.resolvedSymbol.fir as FirFunction<*>)
.toArgumentToParameterMapping()
it.replaceArgumentList(buildResolvedArgumentList(argumentMapping))
}
annotationCall.getCorrespondingConstructorReferenceOrNull(session)?.let { calleeReference ->
val argumentMapping =
mapArguments(it.arguments, calleeReference.resolvedSymbol.fir as FirFunction<*>)
.toArgumentToParameterMapping()
it.replaceArgumentList(buildResolvedArgumentList(argumentMapping))
}
it.replaceResolveStatus(status)
dataFlowAnalyzer.exitAnnotationCall(it)