Support Kotlin extensions in web handlers
This commit restores support for Kotlin extensions in web handlers, and adds support for invoking reflectively suspending extension functions, as well as the other features supported as of Spring Framework 6.1 like value classes and default value for parameters. Closes gh-31876
This commit is contained in:
@@ -318,8 +318,11 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
int index = 0;
|
||||
for (KParameter parameter : function.getParameters()) {
|
||||
switch (parameter.getKind()) {
|
||||
case INSTANCE -> argMap.put(parameter, target);
|
||||
case VALUE -> {
|
||||
case INSTANCE:
|
||||
argMap.put(parameter, target);
|
||||
break;
|
||||
case VALUE:
|
||||
case EXTENSION_RECEIVER:
|
||||
if (!parameter.isOptional() || args[index] != null) {
|
||||
if (parameter.getType().getClassifier() instanceof KClass<?> kClass && kClass.isValue()) {
|
||||
Class<?> javaClass = JvmClassMappingKt.getJavaClass(kClass);
|
||||
@@ -332,7 +335,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
Object result = function.callBy(argMap);
|
||||
|
||||
Reference in New Issue
Block a user