ReduceResult (@NotNull PsiType selectorType, @NotNull PsiElement context, @NotNull Set<? extends PatternDescription> currentPatterns, @NotNull Map<ReduceResultCacheContext, ReduceResult> cache) { currentPatterns = new HashSet<>(currentPatterns); ReduceResultCacheContext cacheContext = new ReduceResultCacheContext(selectorType, currentPatterns); ReduceResult result = cache.get(cacheContext); if (result == null) { result = new ReduceResult(currentPatterns, false) .reduceRecordPatterns(context, cache) .reduceDeconstructionRecordToTypePattern(context) .reduceClasses(selectorType, context); cache.put(cacheContext, result); } return result; }