PsiClassType (@NotNull VarianceCandidate candidate, boolean isExtends) { PsiType type = candidate.type; PsiManager psiManager = candidate.method.getManager(); PsiElementFactory pf = PsiElementFactory.getInstance(psiManager.getProject()); PsiTypeElement newInnerTypeElement = pf.createTypeElement(isExtends ? PsiWildcardType .createExtends(psiManager, type) : PsiWildcardType.createSuper(psiManager, type)); PsiClassReferenceType methodParamType = candidate.methodParameterType; PsiClassReferenceType clone = new PsiClassReferenceType((PsiJavaCodeReferenceElement)methodParamType.getReference().copy(), methodParamType.getLanguageLevel()); PsiJavaCodeReferenceElement cloneReference = clone.getReference(); PsiTypeElement innerTypeElement = cloneReference.getParameterList().getTypeParameterElements()[candidate.typeParameterIndex]; innerTypeElement.replace(newInnerTypeElement); return clone.annotate(methodParamType.getAnnotationProvider()); }