@NotNull
  private static Ref<PyType> getAsClassObjectType(@NotNull PyExpression expression, @NotNull Context context) {
    final PyType type = Ref.deref(getType(expression, context));
    final PyClassType classType = as(type, PyClassType.class);
    if (classType != null && !classType.isDefinition()) {
      return Ref.create(classType.toClass());
    }
    final PyTypeVarType typeVar = as(type, PyTypeVarType.class);
    if (typeVar != null && !typeVar.isDefinition()) {
      return Ref.create(typeVar.toClass());
    }
    // Represent Type[Union[str, int]] internally as Union[Type[str], Type[int]]
    final PyUnionType unionType = as(type, PyUnionType.class);
    if (unionType != null &&
        unionType.getMembers().stream().allMatch(t -> t instanceof PyClassType && !((PyClassType)t).isDefinition())) {
      return Ref.create(PyUnionType.union(ContainerUtil.map(unionType.getMembers(), t -> ((PyClassType)t).toClass())));
    }
    return Ref.create();
  }
@NotNull
  private static Ref<PyType> getAsClassObjectType(@NotNull PyExpression expression, @NotNull Context context)