@@ -164,31 +164,29 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
164164 } else { // first needs converting
165165 // attempt to convert <first> to types that make valid operations with <second>
166166 Class <?> secondClass = second .getReturnType ();
167- Class [] leftTypes = Arithmetics .getOperations (operator ).stream ()
168- .filter (info -> info .getRight ().isAssignableFrom (secondClass ))
169- .map (OperationInfo ::getLeft )
170- .toArray (Class []::new );
171- if (leftTypes .length == 0 ) { // no known operations with second's type
167+ List <? extends OperationInfo <?, ?, ?>> operations = Arithmetics .lookupRightOperations (operator , secondClass );
168+ if (operations .isEmpty ()) { // no known operations with second's type
172169 if (secondClass != Object .class ) // there won't be any operations
173170 return error (first .getReturnType (), secondClass );
174171 first = (Expression <L >) first .getConvertedExpression (Object .class );
175172 } else {
176- first = (Expression <L >) first .getConvertedExpression (leftTypes );
173+ first = (Expression <L >) first .getConvertedExpression (operations .stream ()
174+ .map (OperationInfo ::getLeft )
175+ .toArray (Class []::new ));
177176 }
178177 }
179178 } else if (second instanceof UnparsedLiteral ) { // second needs converting
180179 // attempt to convert <second> to types that make valid operations with <first>
181180 Class <?> firstClass = first .getReturnType ();
182- List <? extends OperationInfo <?, ?, ?>> operations = Arithmetics .getOperations (operator , firstClass );
181+ List <? extends OperationInfo <?, ?, ?>> operations = Arithmetics .lookupLeftOperations (operator , firstClass );
183182 if (operations .isEmpty ()) { // no known operations with first's type
184183 if (firstClass != Object .class ) // there won't be any operations
185184 return error (firstClass , second .getReturnType ());
186185 second = (Expression <R >) second .getConvertedExpression (Object .class );
187186 } else {
188187 second = (Expression <R >) second .getConvertedExpression (operations .stream ()
189188 .map (OperationInfo ::getRight )
190- .toArray (Class []::new )
191- );
189+ .toArray (Class []::new ));
192190 }
193191 }
194192
@@ -223,14 +221,13 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
223221 Class <?>[] returnTypes = null ;
224222 if (!(firstClass == Object .class && secondClass == Object .class )) { // both aren't object
225223 if (firstClass == Object .class ) {
226- returnTypes = Arithmetics .getOperations (operator ).stream ()
227- .filter (info -> info .getRight ().isAssignableFrom (secondClass ))
224+ returnTypes = Arithmetics .lookupRightOperations (operator , secondClass ).stream ()
228225 .map (OperationInfo ::getReturnType )
229226 .toArray (Class []::new );
230227 } else { // secondClass is Object
231- returnTypes = Arithmetics .getOperations (operator , firstClass ).stream ()
232- .map (OperationInfo ::getReturnType )
233- .toArray (Class []::new );
228+ returnTypes = Arithmetics .lookupLeftOperations (operator , firstClass ).stream ()
229+ .map (OperationInfo ::getReturnType )
230+ .toArray (Class []::new );
234231 }
235232 }
236233 if (returnTypes == null ) { // both are object; can't determine anything
0 commit comments