EA-40964
Don't access elements of an empty array
This commit is contained in:
+3
-1
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user