@NotNull
  private static PsiClassType obtainSafeSuperType(@NotNull PsiTypeParameter typeParameter) {
    final PsiClassType superType = typeParameter.getSuperTypes()[0];
    final PsiClassType.ClassResolveResult result = superType.resolveGenerics();
    final PsiClass superClass = result.getElement();
    if (superClass != null) {
      PsiElementFactory factory = JavaPsiFacade.getElementFactory(typeParameter.getProject());
      if (superClass instanceof PsiTypeParameter && InheritanceUtil.getCircularClass(superClass) != null) {
        return factory.createTypeByFQClassName(JAVA_LANG_OBJECT, typeParameter.getResolveScope());
      }
      final PsiSubstitutor substitutor = result.getSubstitutor().put(typeParameter, null);
      return factory.createType(superClass, substitutor);
    }
    return superType;
  }
@NotNull
  private static PsiClassType obtainSafeSuperType(@NotNull PsiTypeParameter typeParameter)