Merge branch '6.0.x'
This commit is contained in:
@@ -74,21 +74,17 @@ public class KotlinReflectionParameterNameDiscoverer implements ParameterNameDis
|
||||
|
||||
@Nullable
|
||||
private String[] getParameterNames(List<KParameter> parameters) {
|
||||
List<KParameter> filteredParameters = parameters
|
||||
.stream()
|
||||
String[] parameterNames = parameters.stream()
|
||||
// Extension receivers of extension methods must be included as they appear as normal method parameters in Java
|
||||
.filter(p -> KParameter.Kind.VALUE.equals(p.getKind()) || KParameter.Kind.EXTENSION_RECEIVER.equals(p.getKind()))
|
||||
.toList();
|
||||
String[] parameterNames = new String[filteredParameters.size()];
|
||||
for (int i = 0; i < filteredParameters.size(); i++) {
|
||||
KParameter parameter = filteredParameters.get(i);
|
||||
// extension receivers are not explicitly named, but require a name for Java interoperability
|
||||
// $receiver is not a valid Kotlin identifier, but valid in Java, so it can be used here
|
||||
String name = KParameter.Kind.EXTENSION_RECEIVER.equals(parameter.getKind()) ? "$receiver" : parameter.getName();
|
||||
if (name == null) {
|
||||
// extension receivers are not explicitly named, but require a name for Java interoperability
|
||||
// $receiver is not a valid Kotlin identifier, but valid in Java, so it can be used here
|
||||
.map(p -> KParameter.Kind.EXTENSION_RECEIVER.equals(p.getKind()) ? "$receiver" : p.getName())
|
||||
.toArray(String[]::new);
|
||||
for (String parameterName : parameterNames) {
|
||||
if (parameterName == null) {
|
||||
return null;
|
||||
}
|
||||
parameterNames[i] = name;
|
||||
}
|
||||
return parameterNames;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class KotlinCoroutinesUtilsTests {
|
||||
fun deferredToMono() {
|
||||
runBlocking {
|
||||
val deferred: Deferred<String> = async(Dispatchers.IO) {
|
||||
delay(10)
|
||||
delay(1)
|
||||
"foo"
|
||||
}
|
||||
val mono = CoroutinesUtils.deferredToMono(deferred)
|
||||
@@ -122,12 +122,12 @@ class KotlinCoroutinesUtilsTests {
|
||||
}
|
||||
|
||||
suspend fun suspendingFunction(value: String): String {
|
||||
delay(10)
|
||||
delay(1)
|
||||
return value
|
||||
}
|
||||
|
||||
suspend fun suspendingFunctionWithFlow(): Flow<String> {
|
||||
delay(10)
|
||||
delay(1)
|
||||
return flowOf("foo", "bar")
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class KotlinCoroutinesUtilsTests {
|
||||
}
|
||||
|
||||
suspend fun suspendingFunctionWithContext(value: String): String {
|
||||
delay(10)
|
||||
delay(1)
|
||||
Assertions.assertThat(coroutineContext[CoroutineName]?.name).isEqualTo("name")
|
||||
return value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user