Don't access elements of an empty array
This commit is contained in:
Alexander Udalov
2012-11-28 15:02:37 +04:00
parent 9dd167a760
commit b23601eefe
3 changed files with 16 additions and 1 deletions
@@ -1437,7 +1437,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
List<JetExpression> indices = arrayAccessExpression.getIndexExpressions();
// The accumulated data flow info of all index expressions is saved on the last index
dataFlowInfo = facade.getTypeInfo(indices.get(indices.size() - 1), context).getDataFlowInfo();
if (!indices.isEmpty()) {
dataFlowInfo = facade.getTypeInfo(indices.get(indices.size() - 1), context).getDataFlowInfo();
}
if (!isGet) {
dataFlowInfo = facade.getTypeInfo(rightHandSide, context.replaceDataFlowInfo(dataFlowInfo)).getDataFlowInfo();
@@ -0,0 +1,8 @@
package checkFiles
import java.util.HashMap
fun main(args: Array<String>) {
val hashMap = HashMap<String, String>()
hashMap[<!SYNTAX!><!>]
}
@@ -2955,6 +2955,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/regressions/DoubleDefine.kt");
}
@TestMetadata("ea40964.kt")
public void testEa40964() throws Exception {
doTest("compiler/testData/diagnostics/tests/regressions/ea40964.kt");
}
@TestMetadata("ErrorsOnIbjectExpressionsAsParameters.kt")
public void testErrorsOnIbjectExpressionsAsParameters() throws Exception {
doTest("compiler/testData/diagnostics/tests/regressions/ErrorsOnIbjectExpressionsAsParameters.kt");