@@ -231,8 +231,9 @@ private void resolveOpDependencies(Object obj, OpCandidate parentOp) throws OpMa
231231
232232 @ SuppressWarnings ("unchecked" )
233233 public <T > T findOpInstance (final String opName , final Nil <T > specialType , final Nil <?>[] inTypes ,
234- final Nil <?>[] outTypes , final Object ... secondaryArgs ) {
235- final OpRef ref = OpRef .fromTypes (opName , toTypes (specialType ), toTypes (outTypes ), toTypes (inTypes ));
234+ final Nil <?> outType , final Object ... secondaryArgs ) {
235+ final OpRef ref = OpRef .fromTypes (opName , toTypes (specialType ), outType != null ? outType .getType () : null , toTypes (
236+ inTypes ));
236237 return (T ) findOpInstance (opName , ref , secondaryArgs );
237238 }
238239
@@ -278,14 +279,9 @@ else if (transformation != null)
278279 return op ;
279280 }
280281
281- public <T > T findOp (final String opName , final Nil <T > specialType , final Nil <?>[] inTypes , final Nil <?>[] outTypes ,
282- final Object ... secondaryArgs ) {
283- return findOpInstance (opName , specialType , inTypes , outTypes , secondaryArgs );
284- }
285-
286282 public <T > T findOp (final String opName , final Nil <T > specialType , final Nil <?>[] inTypes , final Nil <?> outType ,
287283 final Object ... secondaryArgs ) {
288- return findOpInstance (opName , specialType , inTypes , new Nil [] { outType } , secondaryArgs );
284+ return findOpInstance (opName , specialType , inTypes , outType , secondaryArgs );
289285 }
290286
291287 private Type [] toTypes (Nil <?>... nils ) {
@@ -295,11 +291,10 @@ private Type[] toTypes(Nil<?>... nils) {
295291 public Object run (final String opName , final Object ... args ) {
296292
297293 Nil <?>[] inTypes = Arrays .stream (args ).map (arg -> Nil .of (typeService .reify (arg ))).toArray (Nil []::new );
298- Nil <?>[] outTypes = new Nil <?>[] { new Nil <Object >() {
299- } };
294+ Nil <?> outType = new Nil <Object >() {};
300295
301296 OpRunner <Object > op = findOpInstance (opName , new Nil <OpRunner <Object >>() {
302- }, inTypes , outTypes );
297+ }, inTypes , outType );
303298
304299 // TODO change
305300 return op .run (args );
@@ -329,7 +324,9 @@ public Object run(final String opName, final Object... args) {
329324 * @param name
330325 * @return null if the specified type has no functional method
331326 */
332- private OpRef inferOpRef (Type type , String name , Map <TypeVariable <?>, Type > typeVarAssigns ) {
327+ private OpRef inferOpRef (Type type , String name , Map <TypeVariable <?>, Type > typeVarAssigns )
328+ throws OpMatchingException
329+ {
333330 List <FunctionalMethodType > fmts = ParameterStructs .getFunctionalMethodTypes (type );
334331 if (fmts == null )
335332 return null ;
@@ -346,7 +343,16 @@ private OpRef inferOpRef(Type type, String name, Map<TypeVariable<?>, Type> type
346343 Type [] mappedInputs = Types .mapVarToTypes (inputs , typeVarAssigns );
347344 Type [] mappedOutputs = Types .mapVarToTypes (outputs , typeVarAssigns );
348345
349- return new OpRef (name , new Type [] { type }, mappedOutputs , mappedInputs );
346+ final int numOutputs = mappedOutputs .length ;
347+ if (numOutputs != 1 ) {
348+ String error = "Op '" + name + "' of type " + type + " specifies " ;
349+ error += numOutputs == 0 //
350+ ? "no outputs" //
351+ : "multiple outputs: " + Arrays .toString (outputs );
352+ error += ". This is not supported." ;
353+ throw new OpMatchingException (error );
354+ }
355+ return new OpRef (name , new Type [] { type }, mappedOutputs [0 ], mappedInputs );
350356 }
351357
352358 /**
0 commit comments