Merge branch '6.1.x'
This commit is contained in:
@@ -130,7 +130,11 @@ public abstract class CoroutinesUtils {
|
||||
KType type = parameter.getType();
|
||||
if (!(type.isMarkedNullable() && arg == null) && type.getClassifier() instanceof KClass<?> kClass
|
||||
&& KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
||||
KFunction<?> constructor = KClasses.getPrimaryConstructor(kClass);
|
||||
if (!KCallablesJvm.isAccessible(constructor)) {
|
||||
KCallablesJvm.setAccessible(constructor, true);
|
||||
}
|
||||
arg = constructor.call(arg);
|
||||
}
|
||||
argMap.put(parameter, arg);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.coroutineContext
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
|
||||
/**
|
||||
* Kotlin tests for [CoroutinesUtils].
|
||||
@@ -206,6 +208,15 @@ class CoroutinesUtilsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun invokeSuspendingFunctionWithValueClassWithPrivateConstructorParameter() {
|
||||
val method = CoroutinesUtilsTests::class.java.declaredMethods.first { it.name.startsWith("suspendingFunctionWithValueClassWithPrivateConstructor") }
|
||||
val mono = CoroutinesUtils.invokeSuspendingFunction(method, this, "foo", null) as Mono
|
||||
runBlocking {
|
||||
Assertions.assertThat(mono.awaitSingleOrNull()).isEqualTo("foo")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun invokeSuspendingFunctionWithExtension() {
|
||||
val method = CoroutinesUtilsTests::class.java.getDeclaredMethod("suspendingFunctionWithExtension",
|
||||
@@ -293,6 +304,11 @@ class CoroutinesUtilsTests {
|
||||
return value?.value
|
||||
}
|
||||
|
||||
suspend fun suspendingFunctionWithValueClassWithPrivateConstructor(value: ValueClassWithPrivateConstructor): String? {
|
||||
delay(1)
|
||||
return value.value
|
||||
}
|
||||
|
||||
suspend fun CustomException.suspendingFunctionWithExtension(): String {
|
||||
delay(1)
|
||||
return "${this.message}"
|
||||
@@ -331,6 +347,13 @@ class CoroutinesUtilsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class ValueClassWithPrivateConstructor private constructor(val value: String) {
|
||||
companion object {
|
||||
fun from(value: String) = ValueClassWithPrivateConstructor(value)
|
||||
}
|
||||
}
|
||||
|
||||
class CustomException(message: String) : Throwable(message)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user