@Override
  public void visitMethod(@NotNull PsiMethod method) {
    final PsiIdentifier methodNameNode = method.getNameIdentifier();
    final MatchContext context = myMatchingVisitor.getMatchContext();
    final boolean isTypedVar = context.getPattern().isTypedVar(methodNameNode);
    final PsiMethod other = myMatchingVisitor.getElement(PsiMethod.class);
    if (other == null) return;

    context.pushResult();
    try {
      final PsiElement docComment = method.getFirstChild();
      if (docComment instanceof PsiComment && !myMatchingVisitor.setResult(myMatchingVisitor.match(docComment, other.getFirstChild()))) {
        return;
      }
      if (method.hasTypeParameters() && 
          !myMatchingVisitor.setResult(myMatchingVisitor.match(method.getTypeParameterList(), other.getTypeParameterList()))) {
        return;
      }
      if (!myMatchingVisitor.setResult(checkHierarchy(other, method))) {
        return;
      }
      if (!myMatchingVisitor.setResult((!method.isConstructor() || other.isConstructor()) &&
                                       (isTypedVar || myMatchingVisitor.matchText(methodNameNode, other.getNameIdentifier())) &&
                                       myMatchingVisitor.match(method.getModifierList(), other.getModifierList()))) {
        return;
      }
      final PsiParameterList otherParameterList = other.getParameterList();
      final PsiReceiverParameter receiverParameter = PsiTreeUtil.findChildOfType(otherParameterList, PsiReceiverParameter.class);
      if (receiverParameter != null) {
        final PsiParameterList parameterList = method.getParameterList();
        final PsiVariable firstParameter = PsiTreeUtil.findChildOfType(parameterList, PsiVariable.class);
        if (firstParameter != null) {
          final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(firstParameter);
          if (handler instanceof SubstitutionHandler substHandler &&
              substHandler.handle(receiverParameter, context) &&
              !myMatchingVisitor.setResult(substHandler.getMaxOccurs() != 0)) {
            return;
          }
        }
        if (!myMatchingVisitor.setResult(myMatchingVisitor.matchSons(method.getParameterList(), otherParameterList) ||
                                         myMatchingVisitor.matchSequentially(parameterList.getFirstChild(),
                                                                             receiverParameter.getNextSibling()))) {
          return;
        }
      }
      else if (!myMatchingVisitor.setResult(myMatchingVisitor.matchSons(method.getParameterList(), otherParameterList))) {
        return;
      }
      myMatchingVisitor.setResult(myMatchingVisitor.matchOptionally(method.getReturnTypeElement(), other.getReturnTypeElement()) &&
                                  matchInAnyOrder(method.getThrowsList(), other.getThrowsList()) &&
                                  myMatchingVisitor.matchSonsOptionally(method.getBody(), other.getBody()));
    }
    finally {
      myMatchingVisitor.scopeMatch(methodNameNode, isTypedVar, other.getNameIdentifier());
    }
  }
@Override
  public void visitMethod(@NotNull PsiMethod method)