Merge branch '6.1.x'

This commit is contained in:
Sébastien Deleuze
2024-03-21 17:56:14 +01:00
6 changed files with 80 additions and 17 deletions

View File

@@ -226,6 +226,16 @@ class CoroutinesUtilsTests {
}
}
@Test
fun invokeSuspendingFunctionWithGenericParameter() {
val method = GenericController::class.java.declaredMethods.first { it.name.startsWith("handle") }
val horse = Animal("horse")
val mono = CoroutinesUtils.invokeSuspendingFunction(method, AnimalController(), horse, null) as Mono
runBlocking {
Assertions.assertThat(mono.awaitSingle()).isEqualTo(horse.name)
}
}
suspend fun suspendingFunction(value: String): String {
delay(1)
return value
@@ -293,6 +303,22 @@ class CoroutinesUtilsTests {
return "${this.message}-$limit"
}
interface Named {
val name: String
}
data class Animal(override val name: String) : Named
abstract class GenericController<T : Named> {
suspend fun handle(named: T): String {
delay(1)
return named.name;
}
}
private class AnimalController : GenericController<Animal>()
@JvmInline
value class ValueClass(val value: String)