Implement suspend lambdas of big arity

Suspend functions and callable references to suspend lambdas are already
supported.
Support callSuspendBy of suspend function of big arity.
 #KT-24854: Fixed
This commit is contained in:
Ilmir Usmanov
2018-08-28 21:47:22 +03:00
parent 769344569d
commit f3879af9f6
17 changed files with 297 additions and 20 deletions
@@ -726,7 +726,7 @@ public class AsmUtil {
if (descriptor.isOperator()) {
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
if (receiverParameter != null) {
genParamAssertion(v, state.getTypeMapper(), frameMap, receiverParameter, "$receiver");
genParamAssertion(v, state.getTypeMapper(), frameMap, receiverParameter, "$receiver", descriptor);
}
}
return;
@@ -734,11 +734,11 @@ public class AsmUtil {
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
if (receiverParameter != null) {
genParamAssertion(v, state.getTypeMapper(), frameMap, receiverParameter, "$receiver");
genParamAssertion(v, state.getTypeMapper(), frameMap, receiverParameter, "$receiver", descriptor);
}
for (ValueParameterDescriptor parameter : descriptor.getValueParameters()) {
genParamAssertion(v, state.getTypeMapper(), frameMap, parameter, parameter.getName().asString());
genParamAssertion(v, state.getTypeMapper(), frameMap, parameter, parameter.getName().asString(), descriptor);
}
}
@@ -747,7 +747,8 @@ public class AsmUtil {
@NotNull KotlinTypeMapper typeMapper,
@NotNull FrameMap frameMap,
@NotNull ParameterDescriptor parameter,
@NotNull String name
@NotNull String name,
@NotNull FunctionDescriptor containingDeclaration
) {
KotlinType type = parameter.getType();
if (isNullableType(type) || InlineClassesUtilsKt.isNullableUnderlyingType(type)) return;
@@ -755,7 +756,8 @@ public class AsmUtil {
Type asmType = typeMapper.mapType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
StackValue value;
if (JvmCodegenUtil.isDeclarationOfBigArityFunctionInvoke(parameter.getContainingDeclaration())) {
if (JvmCodegenUtil.isDeclarationOfBigArityFunctionInvoke(containingDeclaration) ||
JvmCodegenUtil.isDeclarationOfBigArityCreateCoroutineMethod(containingDeclaration)) {
int index = getIndexOfParameterInVarargInvokeArray(parameter);
value = StackValue.arrayElement(
OBJECT_TYPE, null, StackValue.local(1, getArrayType(OBJECT_TYPE)), StackValue.constant(index)
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.codegen.context.RootContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
@@ -46,6 +47,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions;
import java.io.File;
import static org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt.SUSPEND_FUNCTION_CREATE_METHOD_NAME;
import static org.jetbrains.kotlin.descriptors.ClassKind.ANNOTATION_CLASS;
import static org.jetbrains.kotlin.descriptors.ClassKind.INTERFACE;
import static org.jetbrains.kotlin.descriptors.Modality.ABSTRACT;
@@ -358,6 +360,12 @@ public class JvmCodegenUtil {
return descriptor instanceof FunctionInvokeDescriptor && ((FunctionInvokeDescriptor) descriptor).hasBigArity();
}
public static boolean isDeclarationOfBigArityCreateCoroutineMethod(@Nullable DeclarationDescriptor descriptor) {
return descriptor instanceof SimpleFunctionDescriptor && descriptor.getName().asString().equals(SUSPEND_FUNCTION_CREATE_METHOD_NAME) &&
((SimpleFunctionDescriptor) descriptor).getValueParameters().size() >= FunctionInvokeDescriptor.BIG_ARITY - 1 &&
descriptor.getContainingDeclaration() instanceof AnonymousFunctionDescriptor && ((AnonymousFunctionDescriptor) descriptor.getContainingDeclaration()).isSuspend();
}
public static boolean isOverrideOfBigArityFunctionInvoke(@Nullable DeclarationDescriptor descriptor) {
return descriptor instanceof FunctionDescriptor &&
descriptor.getName().equals(OperatorNameConventions.INVOKE) &&
@@ -338,6 +338,7 @@ class CoroutineCodegenForLambda private constructor(
val owner = typeMapper.mapClass(classDescriptor)
val thisInstance = StackValue.thisOrOuter(codegen, classDescriptor, false, false)
val isBigArity = JvmCodegenUtil.isDeclarationOfBigArityCreateCoroutineMethod(createCoroutineDescriptor)
with(codegen.v) {
anew(owner)
@@ -350,10 +351,16 @@ class CoroutineCodegenForLambda private constructor(
}
// load resultContinuation
if (generateErasedCreate) {
load(allFunctionParameters().size + 1, AsmTypes.OBJECT_TYPE)
if (isBigArity) {
load(1, AsmTypes.OBJECT_TYPE)
iconst(allFunctionParameters().size)
aload(AsmTypes.OBJECT_TYPE)
} else {
load(allFunctionParameters().map { typeMapper.mapType(it.type).size }.sum() + 1, AsmTypes.OBJECT_TYPE)
if (generateErasedCreate) {
load(allFunctionParameters().size + 1, AsmTypes.OBJECT_TYPE)
} else {
load(allFunctionParameters().map { typeMapper.mapType(it.type).size }.sum() + 1, AsmTypes.OBJECT_TYPE)
}
}
invokespecial(owner.internalName, constructorToUseFromInvoke.name, constructorToUseFromInvoke.descriptor, false)
@@ -365,20 +372,33 @@ class CoroutineCodegenForLambda private constructor(
var index = 1
for (parameter in allFunctionParameters()) {
val fieldInfoForCoroutineLambdaParameter = parameter.getFieldInfoForCoroutineLambdaParameter()
if (generateErasedCreate) {
load(index, AsmTypes.OBJECT_TYPE)
if (isBigArity) {
load(cloneIndex, fieldInfoForCoroutineLambdaParameter.ownerType)
load(1, AsmTypes.OBJECT_TYPE)
iconst(index - 1)
aload(AsmTypes.OBJECT_TYPE)
StackValue.coerce(AsmTypes.OBJECT_TYPE, fieldInfoForCoroutineLambdaParameter.fieldType, this)
putfield(
fieldInfoForCoroutineLambdaParameter.ownerInternalName,
fieldInfoForCoroutineLambdaParameter.fieldName,
fieldInfoForCoroutineLambdaParameter.fieldType.descriptor
)
} else {
load(index, fieldInfoForCoroutineLambdaParameter.fieldType)
if (generateErasedCreate) {
load(index, AsmTypes.OBJECT_TYPE)
StackValue.coerce(AsmTypes.OBJECT_TYPE, fieldInfoForCoroutineLambdaParameter.fieldType, this)
} else {
load(index, fieldInfoForCoroutineLambdaParameter.fieldType)
}
AsmUtil.genAssignInstanceFieldFromParam(
fieldInfoForCoroutineLambdaParameter,
index,
this,
cloneIndex,
generateErasedCreate
)
}
AsmUtil.genAssignInstanceFieldFromParam(
fieldInfoForCoroutineLambdaParameter,
index,
this,
cloneIndex,
generateErasedCreate
)
index += fieldInfoForCoroutineLambdaParameter.fieldType.size
index += if (isBigArity || generateErasedCreate) 1 else fieldInfoForCoroutineLambdaParameter.fieldType.size
}
load(cloneIndex, AsmTypes.OBJECT_TYPE)
@@ -1203,7 +1203,7 @@ public class KotlinTypeMapper {
skipGenericSignature);
}
if (isDeclarationOfBigArityFunctionInvoke(f)) {
if (isDeclarationOfBigArityFunctionInvoke(f) || isDeclarationOfBigArityCreateCoroutineMethod(f)) {
KotlinBuiltIns builtIns = DescriptorUtilsKt.getBuiltIns(f);
KotlinType arrayOfNullableAny = builtIns.getArrayType(Variance.INVARIANT, builtIns.getNullableAnyType());
return mapSignatureWithCustomParameters(f, kind, Stream.of(arrayOfNullableAny), false, false);
@@ -0,0 +1,27 @@
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
// CHECK_BYTECODE_LISTING
import helpers.*
import COROUTINES_PACKAGE.*
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun call(c: suspend Long.() -> String): String {
return 1000L.c()
}
fun box(): String {
var res = ""
builder {
res = call { ->
"OK$this"
}
}
if (res != "OK1000") return res
return "OK"
}
@@ -0,0 +1,34 @@
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithLongReceiverKt$box$1$1 {
field label: int
private field p$: long
inner class LambdaWithLongReceiverKt$box$1
inner class LambdaWithLongReceiverKt$box$1$1
method <init>(p0: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
public final method invoke(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
}
@kotlin.coroutines.jvm.internal.DebugMetadata
@kotlin.Metadata
final class LambdaWithLongReceiverKt$box$1 {
synthetic final field $res: kotlin.jvm.internal.Ref$ObjectRef
field L$0: java.lang.Object
field label: int
inner class LambdaWithLongReceiverKt$box$1
inner class LambdaWithLongReceiverKt$box$1$1
method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): kotlin.coroutines.Continuation
public final method invoke(p0: java.lang.Object): java.lang.Object
public final @org.jetbrains.annotations.Nullable method invokeSuspend(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
}
@kotlin.Metadata
public final class LambdaWithLongReceiverKt {
inner class LambdaWithLongReceiverKt$box$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void
public final static @org.jetbrains.annotations.Nullable method call(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function2, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
}
@@ -0,0 +1,30 @@
@kotlin.Metadata
final class LambdaWithLongReceiverKt$box$1$1 {
private field p$: long
inner class LambdaWithLongReceiverKt$box$1
inner class LambdaWithLongReceiverKt$box$1$1
method <init>(p0: kotlin.coroutines.experimental.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.experimental.Continuation): kotlin.coroutines.experimental.Continuation
public final @org.jetbrains.annotations.Nullable method doResume(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Throwable): java.lang.Object
public final method invoke(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
}
@kotlin.Metadata
final class LambdaWithLongReceiverKt$box$1 {
synthetic final field $res: kotlin.jvm.internal.Ref$ObjectRef
field L$0: java.lang.Object
inner class LambdaWithLongReceiverKt$box$1
inner class LambdaWithLongReceiverKt$box$1$1
method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.experimental.Continuation): void
public final @org.jetbrains.annotations.NotNull method create(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.experimental.Continuation): kotlin.coroutines.experimental.Continuation
public final @org.jetbrains.annotations.Nullable method doResume(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Throwable): java.lang.Object
public final method invoke(p0: java.lang.Object): java.lang.Object
}
@kotlin.Metadata
public final class LambdaWithLongReceiverKt {
inner class LambdaWithLongReceiverKt$box$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void
public final static @org.jetbrains.annotations.Nullable method call(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function2, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.experimental.Continuation): java.lang.Object
}
@@ -0,0 +1,47 @@
// !LANGUAGE: +ReleaseCoroutines
// IGNORE_BACKEND: JS_IR, JS, NATIVE, JVM_IR
// WITH_REFLECT
// WITH_COROUTINES
import kotlin.reflect.full.*
import helpers.*
import kotlin.coroutines.*
class A {
suspend fun foo(
p00: Long = 0, p01: A = A(), p02: A = A(), p03: A = A(), p04: A = A(), p05: A = A(), p06: A = A(), p07: A = A(), p08: A = A(), p09: A = A(),
p10: A = A(), p11: A = A(), p12: A = A(), p13: A = A(), p14: A = A(), p15: A = A(), p16: A = A(), p17: A = A(), p18: A = A(), p19: A = A(),
p20: A = A(), p21: A = A(), p22: A = A(), p23: A = A(), p24: A = A(), p25: A = A(), p26: A = A(), p27: A = A(), p28: A = A(), p29: String
): String {
return p29 + p00
}
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
suspend fun expectsLambdaWithBigArity(c: suspend (Long, Long, Long, Long, Long, Long, Long, Long, Long, Long,
Long, Long, Long, Long, Long, Long, Long, Long, Long, Long,
Long, Long, Long, Long, Long, Long, Long, Long, Long, String) -> String): String {
return c.invoke(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, "OK")
}
fun box(): String {
val a = A()
var res = "FAIL 1"
builder {
res = A::foo.callSuspend(a, 1L, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, "OK")
}
if (res != "OK1") return res
res = "FAIL 2"
builder {
res = A::foo.callSuspendBy(mapOf(A::foo.parameters.first() to A(), A::foo.parameters.last() to "OK")) as String
}
if (res != "OK0") return res
res = "FAIL 3"
builder {
res = expectsLambdaWithBigArity { _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, s -> s }
}
return res
}
@@ -0,0 +1,19 @@
// !LANGUAGE: -FunctionTypesWithBigArity
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
class A {
suspend fun foo(
p00: Long = 1, p01: A = A(), p02: A = A(), p03: A = A(), p04: A = A(), p05: A = A(), p06: A = A(), p07: A = A(), p08: A = A(), p09: A = A(),
p10: A = A(), p11: A = A(), p12: A = A(), p13: A = A(), p14: A = A(), p15: A = A(), p16: A = A(), p17: A = A(), p18: A = A(), p19: A = A(),
p20: A = A(), p21: A = A(), p22: A = A(), p23: A = A(), p24: A = A(), p25: A = A(), p26: A = A(), p27: A = A(), p28: A = A(), p29: String
): String {
return p29
}
}
suspend fun expectsLambdaWithBigArity(c: suspend <!UNSUPPORTED_FEATURE!>(Long, Long, Long, Long, Long, Long, Long, Long, Long, Long,
Long, Long, Long, Long, Long, Long, Long, Long, Long, Long,
Long, Long, Long, Long, Long, Long, Long, Long, Long, String) -> String<!>): String {
return c.invoke(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, "OK")
}
@@ -1664,6 +1664,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/bigArity.kt");
}
@TestMetadata("property.kt")
public void testProperty_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental");
@@ -1664,6 +1664,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/bigArity.kt");
}
@TestMetadata("property.kt")
public void testProperty_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental");
@@ -6216,6 +6216,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -6585,6 +6595,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt");
}
@TestMetadata("fromJava.kt")
public void testFromJava() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt");
@@ -6216,6 +6216,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -6585,6 +6595,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt");
}
@TestMetadata("fromJava.kt")
public void testFromJava() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt");
@@ -6216,6 +6216,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -6585,6 +6595,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt");
}
@TestMetadata("fromJava.kt")
public void testFromJava() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt");
@@ -26,6 +26,10 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
FunctionClassDescriptor.Kind.Function.packageFqName.toString() + "." + FunctionClassDescriptor.Kind.Function.classNamePrefix
private val NUMBERED_K_FUNCTION_PREFIX =
FunctionClassDescriptor.Kind.KFunction.packageFqName.toString() + "." + FunctionClassDescriptor.Kind.KFunction.classNamePrefix
private val NUMBERED_SUSPEND_FUNCTION_PREFIX =
FunctionClassDescriptor.Kind.SuspendFunction.packageFqName.toString() + "." + FunctionClassDescriptor.Kind.SuspendFunction.classNamePrefix
private val NUMBERED_K_SUSPEND_FUNCTION_PREFIX =
FunctionClassDescriptor.Kind.KSuspendFunction.packageFqName.toString() + "." + FunctionClassDescriptor.Kind.KSuspendFunction.classNamePrefix
private val FUNCTION_N_CLASS_ID = ClassId.topLevel(FqName("kotlin.jvm.functions.FunctionN"))
private val FUNCTION_N_FQ_NAME = FUNCTION_N_CLASS_ID.asSingleFqName()
@@ -134,13 +138,19 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
* kotlin.Nothing -> java.lang.Void
* kotlin.IntArray -> null
* kotlin.Function3 -> kotlin.jvm.functions.Function3
* kotlin.SuspendFunction3 -> kotlin.jvm.functions.Function4
* kotlin.Function42 -> kotlin.jvm.functions.FunctionN
* kotlin.SuspendFunction42 -> kotlin.jvm.functions.FunctionN
* kotlin.reflect.KFunction3 -> kotlin.reflect.KFunction
* kotlin.reflect.KSuspendFunction3 -> kotlin.reflect.KFunction
* kotlin.reflect.KFunction42 -> kotlin.reflect.KFunction
* kotlin.reflect.KSuspendFunction42 -> kotlin.reflect.KFunction
*/
fun mapKotlinToJava(kotlinFqName: FqNameUnsafe): ClassId? = when {
isKotlinFunctionWithBigArity(kotlinFqName, NUMBERED_FUNCTION_PREFIX) -> FUNCTION_N_CLASS_ID
isKotlinFunctionWithBigArity(kotlinFqName, NUMBERED_SUSPEND_FUNCTION_PREFIX) -> FUNCTION_N_CLASS_ID
isKotlinFunctionWithBigArity(kotlinFqName, NUMBERED_K_FUNCTION_PREFIX) -> K_FUNCTION_CLASS_ID
isKotlinFunctionWithBigArity(kotlinFqName, NUMBERED_K_SUSPEND_FUNCTION_PREFIX) -> K_FUNCTION_CLASS_ID
else -> kotlinToJava[kotlinFqName]
}
@@ -5501,6 +5501,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -5715,6 +5720,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt");
}
@TestMetadata("fromJava.kt")
public void testFromJava() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt");
@@ -5926,6 +5926,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
}
@TestMetadata("lambdaWithLongReceiver.kt")
public void testLambdaWithLongReceiver_1_3() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
}
@TestMetadata("lambdaWithMultipleParameters.kt")
public void testLambdaWithMultipleParameters_1_2() throws Exception {
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithMultipleParameters.kt", "kotlin.coroutines.experimental");
@@ -6285,6 +6295,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("bigArity.kt")
public void testBigArity() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt");
}
@TestMetadata("fromJava.kt")
public void testFromJava() throws Exception {
runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt");