diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java
index cec6437744a..856b5d0baa8 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java
+++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java
@@ -399,6 +399,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
if (multiParameter != null && loopRange != null) {
JetType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType;
TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType);
+ components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace);
components.multiDeclarationResolver.defineLocalVariablesFromMultiDeclaration(
loopScope, multiParameter, iteratorNextAsReceiver, loopRange, context
);
diff --git a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt
new file mode 100644
index 00000000000..40f31b41934
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt
@@ -0,0 +1,14 @@
+annotation class Ann(val x: Int)
+
+data class A(val x: Int, val y: Int)
+
+fun bar(): Array = null!!
+
+fun foo() {
+ for (Ann(1) i in 1..100) {}
+ for (Ann(2) i in 1..100) {}
+
+ for (Ann(3) (x, @Ann(4) y) in bar()) {}
+
+ for (Err (x,y) in bar()) {}
+}
diff --git a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt
new file mode 100644
index 00000000000..585ecd5808b
--- /dev/null
+++ b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt
@@ -0,0 +1,24 @@
+package
+
+internal fun bar(): kotlin.Array
+internal fun foo(): kotlin.Unit
+
+kotlin.data() internal final class A {
+ public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int)
+ internal final val x: kotlin.Int
+ internal final val y: kotlin.Int
+ internal final /*synthesized*/ fun component1(): kotlin.Int
+ internal final /*synthesized*/ fun component2(): kotlin.Int
+ public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): A
+ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
+ public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
+ public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
+}
+
+internal final annotation class Ann : kotlin.Annotation {
+ public constructor Ann(/*0*/ x: kotlin.Int)
+ internal final val x: kotlin.Int
+ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
+ public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
+ public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
+}
diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
index e1189fe8455..95ec5592f75 100644
--- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java
@@ -699,6 +699,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
+ @TestMetadata("forParameterAnnotationResolve.kt")
+ public void testForParameterAnnotationResolve() throws Exception {
+ String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt");
+ doTest(fileName);
+ }
+
@TestMetadata("invalidTypesInAnnotationConstructor.kt")
public void testInvalidTypesInAnnotationConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.kt");