@@ -197,26 +197,16 @@ private SortedSet<OpInfo> filterInfos(SortedSet<OpInfo> infos, Hints hints) {
197197 }
198198
199199 @ Override
200- public <T > T op (final String opName , final Nil <T > specialType ,
201- final Nil <?>[] inTypes , final Nil <?> outType )
202- {
203- return op (opName , specialType , inTypes , outType , getDefaultHints ());
204- }
205-
206- @ Override
207- public <T > T op (final String opName , final Nil <T > specialType ,
208- final Nil <?>[] inTypes , final Nil <?> outType , Hints hints )
209- {
200+ public <T > T op ( //
201+ final String opName , //
202+ final Nil <T > specialType , //
203+ final Nil <?>[] inTypes , //
204+ final Nil <?> outType , //
205+ Hints hints //
206+ ) {
210207 return findOp (opName , specialType , inTypes , outType , hints ).asOpType ();
211208 }
212209
213- @ Override
214- public InfoTree infoTree (String opName , Nil <?> specialType , Nil <?>[] inTypes ,
215- Nil <?> outType )
216- {
217- return infoTree (opName , specialType , inTypes , outType , getDefaultHints ());
218- }
219-
220210 @ Override
221211 public InfoTree infoTree (String opName , Nil <?> specialType , Nil <?>[] inTypes ,
222212 Nil <?> outType , Hints hints )
@@ -229,14 +219,6 @@ public InfoTree treeFromInfo(OpInfo info, Nil<?> specialType, Hints hints) {
229219 return findOp (info , specialType , hints ).infoTree ();
230220 }
231221
232- @ Override
233- public <T > T opFromSignature (final String signature ,
234- final Nil <T > specialType )
235- {
236- InfoTree info = treeFromID (signature );
237- return opFromInfoChain (info , specialType );
238- }
239-
240222 @ Override
241223 public <T > T opFromInfoChain (final InfoTree tree , final Nil <T > specialType ,
242224 Hints hints )
@@ -271,11 +253,6 @@ public Type genericType(Object obj) {
271253 return typeService .reify (obj );
272254 }
273255
274- @ Override
275- public OpInfo opify (final Class <?> opClass , String ... names ) {
276- return opify (opClass , Priority .NORMAL , names );
277- }
278-
279256 @ Override
280257 public OpInfo opify (final Class <?> opClass , final double priority ,
281258 String ... names )
@@ -398,17 +375,26 @@ private <T> RichOp<T> findOp(final String opName, final Nil<T> specialType,
398375 {
399376 final OpRequest request = DefaultOpRequest .fromTypes (opName , specialType
400377 .getType (), outType != null ? outType .getType () : null , toTypes (inTypes ));
401- MatchingConditions conditions = generateCacheHit (request , hints );
402- return (RichOp <T >) wrapViaCache (conditions );
378+ var conditions = MatchingConditions .from (request , hints );
379+ OpInstance <T > instance = (OpInstance <T >) generateCacheHit (conditions );
380+ return wrapOp (instance , conditions );
403381 }
404382
405383 @ SuppressWarnings ("unchecked" )
406384 private <T > OpInstance <T > findOp (final OpInfo info , final Nil <T > specialType ,
407385 Hints hints ) throws OpMatchingException
408386 {
409387 OpRequest request = new InfoMatchingOpRequest (info , specialType );
410- MatchingConditions conditions = insertCacheHit (request , hints , info );
411- return (OpInstance <T >) getInstance (conditions );
388+
389+ // create new OpCandidate from request and info
390+ OpCandidate candidate = new OpCandidate (this , request , info );
391+
392+ MatchingConditions conditions = MatchingConditions .from (request , hints );
393+ var instance = instantiateOp (candidate , conditions .hints ());
394+
395+ // cache instance
396+ setInstance (conditions , instance );
397+ return (OpInstance <T >) instance ;
412398 }
413399
414400 private Type [] toTypes (Nil <?>... nils ) {
@@ -418,33 +404,6 @@ private Type[] toTypes(Nil<?>... nils) {
418404 .toArray (Type []::new );
419405 }
420406
421- /**
422- * Creates an Op instance from an {@link OpInfo} with the provided
423- * {@link MatchingConditions} as the guidelines for {@link OpInfo} selection.
424- * This Op instance is put into the {@link #opCache}, and is retrievable via
425- * {@link DefaultOpEnvironment#wrapViaCache(MatchingConditions)}
426- *
427- * @param request the {@link OpRequest} request
428- * @param hints the {@link Hints} containing matching preferences
429- * @param info the {@link OpInfo} describing the Op that should match these
430- * conditions1
431- * @return the {@link MatchingConditions} that will return the Op described by
432- * {@code info} from the op cache
433- */
434- private MatchingConditions insertCacheHit (final OpRequest request , //
435- final Hints hints , //
436- final OpInfo info //
437- ) {
438- MatchingConditions conditions = MatchingConditions .from (request , hints );
439-
440- // create new OpCandidate from request and info
441- OpCandidate candidate = new OpCandidate (this , request , info );
442-
443- instantiateAndCache (conditions , candidate );
444-
445- return conditions ;
446- }
447-
448407 /**
449408 * Finds an Op instance matching the request described by {@link OpRequest}
450409 * {@code request} and stores this Op in {@link #opCache}. NB the return must
@@ -453,40 +412,39 @@ private MatchingConditions insertCacheHit(final OpRequest request, //
453412 * provide that T (since the {@link OpRequest} could require that the Op
454413 * returned is of multiple types).
455414 *
456- * @param request the {@link OpRequest} request
457- * @param hints the {@link Hints} containing matching preferences
458- * @return the {@link MatchingConditions} that will return the Op found from
459- * the op cache
415+ * @param conditions the {@link MatchingConditions} defining a proper match
416+ * @return the {@link OpInstance} generated to satisfy {@code conditions}
460417 */
461- private MatchingConditions generateCacheHit (OpRequest request , Hints hints ) {
462- MatchingConditions conditions = MatchingConditions .from (request , hints );
418+ private OpInstance <?> generateCacheHit (MatchingConditions conditions ) {
463419 // see if the request has been matched already
464420 OpInstance <?> cachedOp = getInstance (conditions );
465- if (cachedOp != null ) return conditions ;
421+ if (cachedOp != null ) return cachedOp ;
466422
467423 // obtain suitable OpCandidate
468- OpCandidate candidate = findOpCandidate (conditions .request (), conditions
469- .hints ());
470-
471- instantiateAndCache (conditions , candidate );
472-
473- return conditions ;
474- }
475-
476- private void instantiateAndCache (MatchingConditions conditions ,
477- OpCandidate candidate )
478- {
479- // obtain Op instance (with dependencies)
480- OpInstance <?> op = instantiateOp (candidate , conditions .hints ());
424+ var candidate = findOpCandidate (conditions .request (), conditions .hints ());
425+ var instance = instantiateOp (candidate , conditions .hints ());
481426
482427 // cache instance
483- opCache .putIfAbsent (conditions , op );
428+ setInstance (conditions , instance );
429+ return instance ;
484430 }
485431
486432 private OpInstance <?> getInstance (MatchingConditions conditions ) {
433+ if (conditions .hints ().contains (BaseOpHints .Cache .IGNORE )) {
434+ return null ;
435+ }
487436 return opCache .get (conditions );
488437 }
489438
439+ private void setInstance (MatchingConditions conditions ,
440+ OpInstance <?> instance )
441+ {
442+ if (conditions .hints ().contains (BaseOpHints .Cache .IGNORE )) {
443+ return ;
444+ }
445+ opCache .put (conditions , instance );
446+ }
447+
490448 private OpCandidate findOpCandidate (OpRequest request , Hints hints ) {
491449 return matcher .match (MatchingConditions .from (request , hints ), this );
492450 }
@@ -631,18 +589,19 @@ private List<RichOp<?>> resolveOpDependencies(OpInfo info,
631589 // Then, match dependencies
632590 final List <RichOp <?>> dependencyChains = new ArrayList <>();
633591 for (final OpDependencyMember <?> dependency : Infos .dependencies (info )) {
634- final OpRequest dep = inferOpRequest (dependency ,
592+ final OpRequest request = inferOpRequest (dependency ,
635593 dependencyTypeVarAssigns );
636594 try {
637- // Add hints requested by the dependency
638- Hints depHints = baseDepHints .plus (dependency .hints ());
595+ var conditions = MatchingConditions .from (request ,
596+ // Add hints requested by the dependency
597+ baseDepHints .plus (dependency .hints ()));
639598
640- MatchingConditions conditions = generateCacheHit (dep , depHints );
641- dependencyChains .add (wrapViaCache ( conditions ));
599+ OpInstance <?> instance = generateCacheHit (conditions );
600+ dependencyChains .add (wrapOp ( instance , conditions ));
642601 }
643602 catch (final OpMatchingException e ) {
644603 String message = DependencyMatchingException .message (info
645- .implementationName (), dependency .getKey (), dep );
604+ .implementationName (), dependency .getKey (), request );
646605 if (e instanceof DependencyMatchingException ) {
647606 throw new DependencyMatchingException (message ,
648607 (DependencyMatchingException ) e );
@@ -662,11 +621,6 @@ private OpRequest inferOpRequest(OpDependencyMember<?> dependency,
662621 return inferOpRequest (mappedDependencyType , dependencyName , typeVarAssigns );
663622 }
664623
665- private RichOp <?> wrapViaCache (MatchingConditions conditions ) {
666- OpInstance <?> instance = getInstance (conditions );
667- return wrapOp (instance , conditions );
668- }
669-
670624 /**
671625 * Tries to infer a {@link OpRequest} from a functional Op type. E.g. the
672626 * type:
0 commit comments