void (@NotNull final PsiJavaCodeReferenceElement ref, JavaResolveResult @NotNull [] result) { if (result.length > 0 && result[0].getElement() instanceof PsiClass) { PsiDeconstructionPattern pattern = ObjectUtils.tryCast(ref.getParent().getParent(), PsiDeconstructionPattern.class); for (int i = 0; i < result.length; i++) { final CandidateInfo resolveResult = (CandidateInfo)result[i]; final PsiElement resultElement = resolveResult.getElement(); if (resultElement instanceof PsiClass) { PsiClass resultClass = (PsiClass)resultElement; if (resultClass.hasTypeParameters()) { PsiSubstitutor substitutor = resolveResult.getSubstitutor(); result[i] = pattern != null && ref.getTypeParameterCount() == 0 ? PatternInference.inferPatternGenerics(resolveResult, pattern, resultClass, JavaPsiPatternUtil.getContextType(pattern)) : new CandidateInfo(resolveResult, substitutor) { @NotNull @Override public PsiSubstitutor getSubstitutor() { PsiType[] parameters = ref.getTypeParameters(); return super.getSubstitutor().putAll(resultClass, parameters); } }; } } } } }