[FIR] Support of type arguments in annotations ^KT-48444 Fixed

This commit is contained in:
Ivan Kochurkin
2022-04-06 20:54:26 +03:00
committed by teamcity
parent 05bed8f751
commit 8c7fad9a5e
26 changed files with 465 additions and 36 deletions
@@ -377,7 +377,8 @@ class DeclarationsConverter(
CONSTRUCTOR_CALLEE -> constructorCalleePair = convertConstructorInvocation(unescapedAnnotation)
}
}
val name = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("<no-annotation-name>")
val qualifier = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last()
val name = qualifier?.name ?: Name.special("<no-annotation-name>")
return buildAnnotationCall {
source = unescapedAnnotation.toFirSourceElement()
useSiteTarget = annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget
@@ -392,6 +393,7 @@ class DeclarationsConverter(
this.name = name
}
extractArgumentsFrom(constructorCalleePair.second)
typeArguments += qualifier?.typeArgumentList?.typeArguments ?: listOf()
}
}
@@ -1738,9 +1738,7 @@ open class RawFirBuilder(
referenceExpression!!.toFirSourceElement(),
referenceExpression!!.getReferencedNameAsName(),
FirTypeArgumentListImpl(ktQualifier?.typeArgumentList?.toKtPsiSourceElement() ?: source).apply {
for (typeArgument in ktQualifier!!.typeArguments) {
typeArguments += typeArgument.convert<FirTypeProjection>()
}
typeArguments.appendTypeArguments(ktQualifier!!.typeArguments)
}
)
qualifier.add(firQualifier)
@@ -1809,6 +1807,7 @@ open class RawFirBuilder(
source = (annotationEntry.typeReference?.typeElement as? KtUserType)?.referenceExpression?.toFirSourceElement()
this.name = name
}
typeArguments.appendTypeArguments(annotationEntry.typeArguments)
}
}
@@ -2358,9 +2357,7 @@ open class RawFirBuilder(
return result.apply {
this.explicitReceiver = explicitReceiver
for (typeArgument in expression.typeArguments) {
typeArguments += typeArgument.convert<FirTypeProjection>()
}
typeArguments.appendTypeArguments(expression.typeArguments)
}.build()
}
@@ -2537,6 +2534,12 @@ open class RawFirBuilder(
source = expression.toFirSourceElement()
}
}
private fun MutableList<FirTypeProjection>.appendTypeArguments(args: List<KtTypeProjection>) {
for (typeArgument in args) {
this += typeArgument.convert<FirTypeProjection>()
}
}
}
}