Fix IteratorNext intrinsic to cast its dispatch receiver to

the expected type.

^KT-47741 Fixed.
This commit is contained in:
Mads Ager
2021-07-15 14:51:09 +02:00
committed by Alexander Udalov
parent f83cc69379
commit b51ff799cb
10 changed files with 51 additions and 2 deletions
@@ -3465,6 +3465,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@Test
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@Test
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
@@ -33,8 +33,8 @@ object IteratorNext : IntrinsicMethod() {
// If the array element type is unboxed primitive, do not unbox. Otherwise AsmUtil.unbox throws exception
val type = if (AsmUtil.isBoxedPrimitiveType(signature.returnType)) AsmUtil.unboxType(signature.returnType) else signature.returnType
val newSignature = signature.newReturnType(type)
return IrIntrinsicFunction.create(expression, newSignature, context, AsmTypes.OBJECT_TYPE) {
val primitiveClassName = getKotlinPrimitiveClassName(type)
val primitiveClassName = getKotlinPrimitiveClassName(type)
return IrIntrinsicFunction.create(expression, newSignature, context, getPrimitiveIteratorType(primitiveClassName)) {
it.invokevirtual(
getPrimitiveIteratorType(primitiveClassName).internalName,
"next${primitiveClassName.asString()}",
@@ -0,0 +1,6 @@
// IGNORE_BACKEND: WASM
fun box(): String {
val generateId = (1 .. Int.MAX_VALUE).iterator()::next
return if (generateId() == 1) "OK" else "FAIL"
}
@@ -3465,6 +3465,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@Test
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@Test
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
@@ -3465,6 +3465,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@Test
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@Test
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
@@ -3027,6 +3027,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt");
@@ -2192,6 +2192,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt");
@@ -2192,6 +2192,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt");
@@ -2192,6 +2192,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt");
@@ -1622,6 +1622,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/callableReference/function/kt32462.kt");
}
@TestMetadata("kt47741.kt")
public void testKt47741() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/kt47741.kt");
}
@TestMetadata("nestedConstructorFromClass.kt")
public void testNestedConstructorFromClass() throws Exception {
runTest("compiler/testData/codegen/box/callableReference/function/nestedConstructorFromClass.kt");