KT-4866 Resolve does not work inside brackets with unresolved reference before
#KT-4866 Fixed
This commit is contained in:
@@ -130,6 +130,11 @@ public class DebugInfoUtil {
|
|||||||
|
|
||||||
boolean resolved = target != null;
|
boolean resolved = target != null;
|
||||||
boolean markedWithError = markedWithErrorElements.containsKey(expression);
|
boolean markedWithError = markedWithErrorElements.containsKey(expression);
|
||||||
|
if (expression instanceof JetArrayAccessExpression &&
|
||||||
|
markedWithErrorElements.containsKey(((JetArrayAccessExpression) expression).getArrayExpression())) {
|
||||||
|
// if 'foo' in 'foo[i]' is unresolved it means 'foo[i]' is unresolved (otherwise 'foo[i]' is marked as 'missing unresolved')
|
||||||
|
markedWithError = true;
|
||||||
|
}
|
||||||
JetType expressionType = bindingContext.get(EXPRESSION_TYPE, expression);
|
JetType expressionType = bindingContext.get(EXPRESSION_TYPE, expression);
|
||||||
DiagnosticFactory factory = markedWithErrorElements.get(expression);
|
DiagnosticFactory factory = markedWithErrorElements.get(expression);
|
||||||
if (declarationDescriptor != null &&
|
if (declarationDescriptor != null &&
|
||||||
|
|||||||
+6
-1
@@ -1230,7 +1230,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
JetTypeInfo arrayTypeInfo = facade.getTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE)
|
JetTypeInfo arrayTypeInfo = facade.getTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE)
|
||||||
.replaceContextDependency(INDEPENDENT));
|
.replaceContextDependency(INDEPENDENT));
|
||||||
JetType arrayType = arrayTypeInfo.getType();
|
JetType arrayType = arrayTypeInfo.getType();
|
||||||
if (arrayType == null) return arrayTypeInfo;
|
if (arrayType == null) {
|
||||||
|
for (JetExpression indexExpression : arrayAccessExpression.getIndexExpressions()) {
|
||||||
|
facade.getTypeInfo(indexExpression, oldContext);
|
||||||
|
}
|
||||||
|
return arrayTypeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
DataFlowInfo dataFlowInfo = arrayTypeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = arrayTypeInfo.getDataFlowInfo();
|
||||||
ExpressionTypingContext context = oldContext.replaceDataFlowInfo(dataFlowInfo);
|
ExpressionTypingContext context = oldContext.replaceDataFlowInfo(dataFlowInfo);
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
//KT-4866 Resolve does not work inside brackets with unresolved reference before
|
||||||
|
|
||||||
|
fun test(i: Int, j: Int) {
|
||||||
|
<!UNRESOLVED_REFERENCE!>foo<!>[i, j]
|
||||||
|
}
|
||||||
@@ -3472,6 +3472,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/kt2014.kt");
|
doTest("compiler/testData/diagnostics/tests/incompleteCode/kt2014.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt4866UnresolvedArrayAccess.kt")
|
||||||
|
public void testKt4866UnresolvedArrayAccess() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/incompleteCode/kt4866UnresolvedArrayAccess.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NoSenselessComparisonForErrorType.kt")
|
@TestMetadata("NoSenselessComparisonForErrorType.kt")
|
||||||
public void testNoSenselessComparisonForErrorType() throws Exception {
|
public void testNoSenselessComparisonForErrorType() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/NoSenselessComparisonForErrorType.kt");
|
doTest("compiler/testData/diagnostics/tests/incompleteCode/NoSenselessComparisonForErrorType.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user