private static PsiType toBound(PsiType type) {
    if (type instanceof PsiWildcardType wildcardType && wildcardType.isExtends()) {
      return wildcardType.getBound();
    }
    if (type instanceof PsiCapturedWildcardType capturedWildcardType) {
      return capturedWildcardType.getUpperBound();
    }
    return type;
  }
private static PsiType toBound(PsiType type)