19
19
import java .lang .reflect .InvocationTargetException ;
20
20
import java .lang .reflect .Method ;
21
21
import java .util .Map ;
22
+ import java .util .Objects ;
22
23
23
24
import kotlin .Unit ;
24
25
import kotlin .coroutines .CoroutineContext ;
@@ -131,11 +132,7 @@ public static Publisher<?> invokeSuspendingFunction(
131
132
if (!(type .isMarkedNullable () && arg == null ) &&
132
133
type .getClassifier () instanceof KClass <?> kClass &&
133
134
KotlinDetector .isInlineClass (JvmClassMappingKt .getJavaClass (kClass ))) {
134
- KFunction <?> constructor = KClasses .getPrimaryConstructor (kClass );
135
- if (!KCallablesJvm .isAccessible (constructor )) {
136
- KCallablesJvm .setAccessible (constructor , true );
137
- }
138
- arg = constructor .call (arg );
135
+ arg = box (kClass , arg );
139
136
}
140
137
argMap .put (parameter , arg );
141
138
}
@@ -161,6 +158,20 @@ public static Publisher<?> invokeSuspendingFunction(
161
158
return mono ;
162
159
}
163
160
161
+ private static Object box (KClass <?> kClass , @ Nullable Object arg ) {
162
+ KFunction <?> constructor = Objects .requireNonNull (KClasses .getPrimaryConstructor (kClass ));
163
+ KType type = constructor .getParameters ().get (0 ).getType ();
164
+ if (!(type .isMarkedNullable () && arg == null ) &&
165
+ type .getClassifier () instanceof KClass <?> parameterClass &&
166
+ KotlinDetector .isInlineClass (JvmClassMappingKt .getJavaClass (parameterClass ))) {
167
+ arg = box (parameterClass , arg );
168
+ }
169
+ if (!KCallablesJvm .isAccessible (constructor )) {
170
+ KCallablesJvm .setAccessible (constructor , true );
171
+ }
172
+ return constructor .call (arg );
173
+ }
174
+
164
175
private static Flux <?> asFlux (Object flow ) {
165
176
return ReactorFlowKt .asFlux (((Flow <?>) flow ));
166
177
}
0 commit comments