@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
                                                 boolean isOnTheFly) {
    if (!PsiUtil.getLanguageLevel(holder.getFile()).isAtLeast(LanguageLevel.JDK_16)) {
      return PsiElementVisitor.EMPTY_VISITOR;
    }

    return new JavaElementVisitor() {
      @Override
      public void visitSynchronizedStatement(@NotNull final PsiSynchronizedStatement statement) {
        final PsiExpression monitor = statement.getLockExpression();
        if (monitor == null) return;

        final PsiType monitorType = monitor.getType();
        if (monitorType == null) return;

        if (!isValueBasedClass(monitorType)) {
          final TypeConstraint constraint = TypeConstraint.fromDfType(CommonDataflow.getDfType(monitor));
          final PsiType inferredType = constraint.getPsiType(statement.getProject());

          if (monitorType.equals(inferredType)) return;

          if (!isValueBasedClass(inferredType)) return;
        }

        holder.registerProblem(monitor, JavaBundle.message("inspection.value.based.warnings.synchronization"));
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder,
                                                 boolean isOnTheFly)