11package org .scijava .ops .engine .util .internal ;
22
33import java .lang .reflect .Method ;
4+ import java .lang .reflect .Parameter ;
45import java .lang .reflect .Type ;
56import java .lang .reflect .TypeVariable ;
67import java .util .Arrays ;
78import java .util .HashMap ;
89import java .util .Map ;
910
11+ import org .scijava .common3 .Classes ;
1012import org .scijava .ops .spi .OpDependency ;
1113import org .scijava .types .Types ;
1214import org .scijava .types .inference .GenericAssignability ;
@@ -36,9 +38,11 @@ public static Type getOpMethodType(Class<?> opClass, Method opMethod) {
3638 GenericAssignability .inferTypeVariables (typeMethodParams , getOpParamTypes (
3739 opMethodParams ), typeVarAssigns );
3840 if (abstractMethod .getReturnType () != void .class ) {
41+ Type returnType = opMethod .getGenericReturnType ();
42+ if (Types .raw (returnType ).isPrimitive ())
43+ returnType = Classes .box (Types .raw (returnType ));
3944 GenericAssignability .inferTypeVariables (new Type [] { abstractMethod
40- .getGenericReturnType () }, new Type [] { opMethod
41- .getGenericReturnType () }, typeVarAssigns );
45+ .getGenericReturnType () }, new Type [] {returnType }, typeVarAssigns );
4246 }
4347
4448 // parameterize opClass
@@ -60,7 +64,9 @@ public static Type[] getOpParamTypes(
6064 return Arrays //
6165 .stream (methodParams ) //
6266 .filter (param -> param .getAnnotation (OpDependency .class ) == null ) //
63- .map (param -> param .getParameterizedType ()).toArray (Type []::new );
67+ .map (Parameter ::getParameterizedType ) //
68+ .map (param -> Types .raw (param ).isPrimitive () ? Classes .box (Types .raw (param )) : param ) //
69+ .toArray (Type []::new );
6470 }
6571
6672}
0 commit comments