Add cast to expected type in call-based in-expression generation

#KT-20106 Fixed
This commit is contained in:
Dmitry Petrov
2017-09-05 11:42:03 +03:00
parent 081b732070
commit 21cdf9dd5b
6 changed files with 32 additions and 0 deletions
@@ -39,6 +39,7 @@ class CallBasedInExpressionGenerator(
object : BranchedValue(argument, null, argument.type, Opcodes.IFEQ) {
override fun putSelector(type: Type, v: InstructionAdapter) {
invokeFunction(v)
coerceTo(type, v)
}
override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) {
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun box(): String {
val strSet = setOf("a", "b")
val xx = "a" to ("a" in strSet)
return if (!xx.second) "fail" else "OK"
}
@@ -13777,6 +13777,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("kt20106.kt")
public void testKt20106() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/kt20106.kt");
doTest(fileName);
}
@TestMetadata("nullableInPrimitiveRange.kt")
public void testNullableInPrimitiveRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt");
@@ -13777,6 +13777,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("kt20106.kt")
public void testKt20106() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/kt20106.kt");
doTest(fileName);
}
@TestMetadata("nullableInPrimitiveRange.kt")
public void testNullableInPrimitiveRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt");
@@ -13777,6 +13777,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("kt20106.kt")
public void testKt20106() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/kt20106.kt");
doTest(fileName);
}
@TestMetadata("nullableInPrimitiveRange.kt")
public void testNullableInPrimitiveRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt");
@@ -15463,6 +15463,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("kt20106.kt")
public void testKt20106() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/kt20106.kt");
doTest(fileName);
}
@TestMetadata("nullableInPrimitiveRange.kt")
public void testNullableInPrimitiveRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt");