KT-4866 Resolve does not work inside brackets with unresolved reference before

#KT-4866 Fixed
This commit is contained in:
Svetlana Isakova
2014-04-28 15:18:22 +04:00
parent 1632025913
commit 5a84ed4497
4 changed files with 21 additions and 1 deletions
@@ -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 &&
@@ -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);
@@ -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");
}
@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");