@NotNull
    private static List<PsiType> findTypes(@Nullable PsiDeconstructionPattern pattern, @NotNull PsiClass record) {
      List<PsiType> recordComponentTypes = Arrays.stream(record.getRecordComponents()).map(t -> t.getType()).toList();
      if (pattern == null) {
        return recordComponentTypes;
      }
      PsiType patternType = pattern.getTypeElement().getType();
      if (patternType instanceof PsiClassType) {
        patternType = PsiUtil.captureToplevelWildcards(patternType, pattern);
        PsiSubstitutor substitutor = ((PsiClassType)patternType).resolveGenerics().getSubstitutor();
        return ContainerUtil.map(recordComponentTypes,
                                 recordComponentType -> JavaVarTypeUtil.getUpwardProjection(substitutor.substitute(recordComponentType)));
      }

      return recordComponentTypes;
    }
@NotNull
    private static List<PsiType> findTypes(@Nullable PsiDeconstructionPattern pattern, @NotNull PsiClass record)