diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java index a6d55e6d1c1..f484fd4d99f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/checkers/DebugInfoUtil.java @@ -130,6 +130,11 @@ public class DebugInfoUtil { boolean resolved = target != null; 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); DiagnosticFactory factory = markedWithErrorElements.get(expression); if (declarationDescriptor != null && diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 6b8855a4b41..206730f3cc6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -1230,7 +1230,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetTypeInfo arrayTypeInfo = facade.getTypeInfo(arrayExpression, oldContext.replaceExpectedType(NO_EXPECTED_TYPE) .replaceContextDependency(INDEPENDENT)); 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(); ExpressionTypingContext context = oldContext.replaceDataFlowInfo(dataFlowInfo); diff --git a/compiler/testData/diagnostics/tests/incompleteCode/kt4866UnresolvedArrayAccess.kt b/compiler/testData/diagnostics/tests/incompleteCode/kt4866UnresolvedArrayAccess.kt new file mode 100644 index 00000000000..34f7d17441e --- /dev/null +++ b/compiler/testData/diagnostics/tests/incompleteCode/kt4866UnresolvedArrayAccess.kt @@ -0,0 +1,5 @@ +//KT-4866 Resolve does not work inside brackets with unresolved reference before + +fun test(i: Int, j: Int) { + foo[i, j] +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 91bf38a216e..c29da23e22e 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3472,6 +3472,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { 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") public void testNoSenselessComparisonForErrorType() throws Exception { doTest("compiler/testData/diagnostics/tests/incompleteCode/NoSenselessComparisonForErrorType.kt");