[FIR] Don't miss annotations on for loops variables

^KT-59874
This commit is contained in:
Nikolay Lunyak
2023-10-27 15:00:50 +03:00
committed by Space Team
parent d03039b949
commit 63f461a6cd
5 changed files with 5 additions and 12 deletions
@@ -1205,7 +1205,8 @@ class LightTreeRawFirExpressionBuilder(
} }
explicitReceiver = generateResolvedAccessExpression(rangeSource, iteratorVal) explicitReceiver = generateResolvedAccessExpression(rangeSource, iteratorVal)
}, },
valueParameter.returnTypeRef valueParameter.returnTypeRef,
extractedAnnotations = valueParameter.annotations
) )
if (multiDeclaration != null) { if (multiDeclaration != null) {
statements.addDestructuringStatements( statements.addDestructuringStatements(
@@ -2645,6 +2645,7 @@ open class PsiRawFirBuilder(
explicitReceiver = generateResolvedAccessExpression(rangeSource, iteratorVal) explicitReceiver = generateResolvedAccessExpression(rangeSource, iteratorVal)
}, },
typeRef = ktParameter.typeReference.toFirOrImplicitType(), typeRef = ktParameter.typeReference.toFirOrImplicitType(),
extractedAnnotations = ktParameter.modifierList?.annotationEntries?.map { it.convert<FirAnnotation>() },
) )
if (multiDeclaration != null) { if (multiDeclaration != null) {
blockBuilder.statements.addDestructuringStatements( blockBuilder.statements.addDestructuringStatements(
@@ -10,5 +10,5 @@ fun foo() {
for (@Ann(3) (x, @Ann(4) y) in bar()) {} for (@Ann(3) (x, @Ann(4) y) in bar()) {}
for (@Err() (x,y) in bar()) {} for (@<!UNRESOLVED_REFERENCE!>Err<!>() (x,y) in bar()) {}
} }
@@ -1,10 +0,0 @@
// See KT-9145
@Target(AnnotationTarget.CLASS)
annotation class Ann
fun foo() {
for (@Ann <!WRONG_MODIFIER_TARGET!>private<!> x in 1..100) {
if (x == 1) return
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// See KT-9145 // See KT-9145
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)