Refine Kotlin inline class optimizations
Closes gh-32334
This commit is contained in:
@@ -26,8 +26,10 @@ import kotlin.jvm.JvmClassMappingKt;
|
||||
import kotlin.reflect.KClass;
|
||||
import kotlin.reflect.KFunction;
|
||||
import kotlin.reflect.KParameter;
|
||||
import kotlin.reflect.KType;
|
||||
import kotlin.reflect.full.KClasses;
|
||||
import kotlin.reflect.jvm.KCallablesJvm;
|
||||
import kotlin.reflect.jvm.KTypesJvm;
|
||||
import kotlin.reflect.jvm.ReflectJvmMapping;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
@@ -315,19 +317,14 @@ public class InvocableHandlerMethod extends HandlerMethod {
|
||||
case VALUE, EXTENSION_RECEIVER -> {
|
||||
Object arg = args[index];
|
||||
if (!(parameter.isOptional() && arg == null)) {
|
||||
if (parameter.getType().getClassifier() instanceof KClass<?> kClass) {
|
||||
Class<?> javaClass = JvmClassMappingKt.getJavaClass(kClass);
|
||||
if (KotlinDetector.isInlineClass(javaClass)
|
||||
&& !(parameter.getType().isMarkedNullable() && arg == null)) {
|
||||
argMap.put(parameter, KClasses.getPrimaryConstructor(kClass).call(arg));
|
||||
}
|
||||
else {
|
||||
argMap.put(parameter, arg);
|
||||
KType type = parameter.getType();
|
||||
if (!(type.isMarkedNullable() && arg == null)) {
|
||||
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
|
||||
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
|
||||
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
argMap.put(parameter, arg);
|
||||
}
|
||||
argMap.put(parameter, arg);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user