FIR: create argument mapping for annotation call in general
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1a861b2df9
commit
4e6bd33eca
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user