Fix typechecker in case of "for ((a, b) in) { }"
Fixes NDFDE
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -414,7 +414,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
KtDestructuringDeclaration multiParameter = expression.getDestructuringParameter();
|
KtDestructuringDeclaration multiParameter = expression.getDestructuringParameter();
|
||||||
if (multiParameter != null && loopRange != null) {
|
if (multiParameter != null) {
|
||||||
KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType;
|
KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType;
|
||||||
TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType);
|
TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType);
|
||||||
components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace);
|
components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace);
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
fun useDeclaredVariables() {
|
||||||
|
for ((a, b)<!SYNTAX!><!>) {
|
||||||
|
<!UNUSED_EXPRESSION, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>
|
||||||
|
<!UNUSED_EXPRESSION, DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>b<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkersShouldRun() {
|
||||||
|
for ((@A a, <!UNDERSCORE_IS_RESERVED!>_<!>)<!SYNTAX!><!>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
annotation class A
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun checkersShouldRun(): kotlin.Unit
|
||||||
|
public fun useDeclaredVariables(): kotlin.Unit
|
||||||
|
|
||||||
|
public final annotation class A : kotlin.Annotation {
|
||||||
|
public constructor 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
|
||||||
|
}
|
||||||
@@ -4493,6 +4493,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ForLoopMissingLoopParameter.kt")
|
||||||
|
public void testForLoopMissingLoopParameter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/declarationChecks/multiDeclarations/ForLoopMissingLoopParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ForLoopWithExtensions.kt")
|
@TestMetadata("ForLoopWithExtensions.kt")
|
||||||
public void testForLoopWithExtensions() throws Exception {
|
public void testForLoopWithExtensions() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/declarationChecks/multiDeclarations/ForLoopWithExtensions.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/declarationChecks/multiDeclarations/ForLoopWithExtensions.kt");
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun main() {
|
||||||
|
for ((i, j)<error>)</error> {}
|
||||||
|
}
|
||||||
@@ -472,6 +472,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("DescructuringDeclarationInForLoop.kt")
|
||||||
|
public void testDescructuringDeclarationInForLoop() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/DescructuringDeclarationInForLoop.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("DoubleDefine.kt")
|
@TestMetadata("DoubleDefine.kt")
|
||||||
public void testDoubleDefine() throws Exception {
|
public void testDoubleDefine() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/DoubleDefine.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/DoubleDefine.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user