PsiType (@NotNull PsiType type) { if (!(type instanceof PsiClassType)) return type; PsiClassType classType = (PsiClassType)type; PsiType[] parameters = classType.getParameters(); boolean changed = false; for (int i = 0; i < parameters.length; i++) { PsiType param = parameters[i]; if (param instanceof PsiWildcardType) { PsiWildcardType wildcardType = (PsiWildcardType)param; PsiClassType bound = ObjectUtils.tryCast(wildcardType.getBound(), PsiClassType.class); if (bound != null && wildcardType.isExtends()) { PsiClass boundClass = PsiUtil.resolveClassInClassTypeOnly(bound); if (boundClass != null && boundClass.hasModifierProperty(PsiModifier.FINAL)) { parameters[i] = bound; changed = true; } } } } if (!changed) return type; PsiClass target = classType.resolve(); if (target == null) return classType; return JavaPsiFacade.getElementFactory(target.getProject()) .createType(target, parameters).annotate(classType.getAnnotationProvider()); }