[FIR] Initialize annotations for block for LightTree
This commit is contained in:
+9
-1
@@ -435,6 +435,7 @@ class ExpressionsConverter(
|
||||
when (it.tokenType) {
|
||||
ANNOTATION -> firAnnotationList += declarationsConverter.convertAnnotation(it)
|
||||
ANNOTATION_ENTRY -> firAnnotationList += declarationsConverter.convertAnnotationEntry(it)
|
||||
BLOCK -> firExpression = declarationsConverter.convertBlockExpression(it)
|
||||
else -> if (it.isExpression()) {
|
||||
context.forwardLabelUsagePermission(annotatedExpression, it)
|
||||
firExpression = getAsFirExpression(it)
|
||||
@@ -442,7 +443,7 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
val result = firExpression ?: buildErrorExpression(null, ConeNotAnnotationContainer(firExpression?.render() ?: "???"))
|
||||
val result = firExpression ?: buildErrorExpression(null, ConeNotAnnotationContainer("???"))
|
||||
require(result is FirAnnotationContainer)
|
||||
(result.annotations as MutableList<FirAnnotation>) += firAnnotationList
|
||||
return result
|
||||
@@ -1149,6 +1150,13 @@ class ExpressionsConverter(
|
||||
body?.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
BLOCK -> firBlock = declarationsConverter.convertBlockExpression(it)
|
||||
ANNOTATED_EXPRESSION -> {
|
||||
if (it.getChildNodeByType(BLOCK) != null) {
|
||||
firBlock = getAsFirExpression(it)
|
||||
} else {
|
||||
firStatement = getAsFirExpression(it)
|
||||
}
|
||||
}
|
||||
else -> if (it.isExpression()) firStatement = getAsFirExpression(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,8 +295,17 @@ open class RawFirBuilder(
|
||||
accept(this@Visitor, Unit) as FirBlock
|
||||
null ->
|
||||
buildEmptyExpressionBlock()
|
||||
else ->
|
||||
FirSingleExpressionBlock(convert())
|
||||
else -> {
|
||||
var firBlock: FirBlock? = null
|
||||
if (this is KtAnnotatedExpression) {
|
||||
val lastChild = children.lastOrNull()
|
||||
if (lastChild is KtBlockExpression) {
|
||||
firBlock = lastChild.toFirBlock()
|
||||
extractAnnotationsTo(firBlock.annotations as MutableList<FirAnnotation>)
|
||||
}
|
||||
}
|
||||
firBlock ?: FirSingleExpressionBlock(convert())
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtDeclarationWithBody.buildFirBody(): Pair<FirBlock?, FirContractDescription?> =
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
// ISSUE: KT-52175
|
||||
|
||||
annotation class Ann
|
||||
annotation class Ann2
|
||||
|
||||
fun test(x: String?) {
|
||||
if (x != null)
|
||||
@Ann() { Unit }
|
||||
@Ann() @Ann2() { Unit } // It should be Block with annotations
|
||||
|
||||
if (x != null)
|
||||
@Ann() @Ann2() Unit // It should be SingleExpressionBlock with annotations
|
||||
}
|
||||
Reference in New Issue
Block a user