KT-3574 Assertion error when using ?: in for range
#KT-3574 Fixed Do not assert that resolvedCall is non-null, since getRangeAsBinaryCall can return a BinaryCall that doesn't represent a range at all (as specified by the comment in getRangeAsBinaryCall)
This commit is contained in:
@@ -466,12 +466,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression);
|
RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression);
|
||||||
if (binaryCall != null) {
|
if (binaryCall != null) {
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(RESOLVED_CALL, binaryCall.op);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(RESOLVED_CALL, binaryCall.op);
|
||||||
assert resolvedCall != null;
|
if (resolvedCall != null) {
|
||||||
|
if (RangeCodegenUtil.isOptimizableRangeTo(resolvedCall.getResultingDescriptor())) {
|
||||||
CallableDescriptor rangeTo = resolvedCall.getResultingDescriptor();
|
generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
|
||||||
if (RangeCodegenUtil.isOptimizableRangeTo(rangeTo)) {
|
return StackValue.none();
|
||||||
generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
|
}
|
||||||
return StackValue.none();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun nil() = null
|
||||||
|
|
||||||
|
fun list() = java.util.Arrays.asList("1")
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
for (x in nil()?:list()) {
|
||||||
|
}
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -1436,6 +1436,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/controlStructures/kt3280.kt");
|
doTest("compiler/testData/codegen/box/controlStructures/kt3280.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt3574.kt")
|
||||||
|
public void testKt3574() throws Exception {
|
||||||
|
doTest("compiler/testData/codegen/box/controlStructures/kt3574.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt416.kt")
|
@TestMetadata("kt416.kt")
|
||||||
public void testKt416() throws Exception {
|
public void testKt416() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/controlStructures/kt416.kt");
|
doTest("compiler/testData/codegen/box/controlStructures/kt416.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user