Skip to content

Commit

Permalink
simplifications - inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jul 1, 2022
1 parent 69b7c7d commit 0156c3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,19 +2129,16 @@ static void jl_init_function(Function *F)
static std::pair<bool, bool> uses_specsig(jl_method_instance_t *lam, jl_value_t *rettype, bool prefer_specsig)
{
size_t nreq = jl_is_method(lam->def.method) ? lam->def.method->nargs : 0;
int va = 0;
if (nreq > 0 && lam->def.method->isva) {
nreq--;
va = 1;
}
jl_value_t *sig = lam->specTypes;
bool needsparams = false;
if (jl_is_method(lam->def.method)) {
if ((size_t)jl_subtype_env_size(lam->def.method->sig) != jl_svec_len(lam->sparam_vals))
needsparams = true;
for (size_t i = 0; i < jl_svec_len(lam->sparam_vals); ++i) {
if (jl_is_typevar(jl_svecref(lam->sparam_vals, i)))
if (jl_is_typevar(jl_svecref(lam->sparam_vals, i))) {
needsparams = true;
break;
}
}
}
if (needsparams)
Expand All @@ -2152,7 +2149,7 @@ static std::pair<bool, bool> uses_specsig(jl_method_instance_t *lam, jl_value_t
return std::make_pair(false, false);
if (jl_nparams(sig) == 0)
return std::make_pair(false, false);
if (va) {
if (nreq > 0 && lam->def.method->isva) {
if (jl_is_vararg(jl_tparam(sig, jl_nparams(sig) - 1)))
return std::make_pair(false, false);
}
Expand Down
8 changes: 4 additions & 4 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int typeenv_has(jl_typeenv_t *env, jl_tvar_t *v) JL_NOTSAFEPOINT

static int layout_uses_free_typevars(jl_value_t *v, jl_typeenv_t *env)
{
if (jl_typeis(v, jl_tvar_type))
if (jl_is_typevar(v))
return !typeenv_has(env, (jl_tvar_t*)v);
if (jl_is_uniontype(v))
return layout_uses_free_typevars(((jl_uniontype_t*)v)->a, env) ||
Expand Down Expand Up @@ -84,7 +84,7 @@ static int layout_uses_free_typevars(jl_value_t *v, jl_typeenv_t *env)

static int has_free_typevars(jl_value_t *v, jl_typeenv_t *env) JL_NOTSAFEPOINT
{
if (jl_typeis(v, jl_tvar_type)) {
if (jl_is_typevar(v)) {
return !typeenv_has(env, (jl_tvar_t*)v);
}
if (jl_is_uniontype(v))
Expand Down Expand Up @@ -125,7 +125,7 @@ JL_DLLEXPORT int jl_has_free_typevars(jl_value_t *v) JL_NOTSAFEPOINT

static void find_free_typevars(jl_value_t *v, jl_typeenv_t *env, jl_array_t *out)
{
if (jl_typeis(v, jl_tvar_type)) {
if (jl_is_typevar(v)) {
if (!typeenv_has(env, (jl_tvar_t*)v))
jl_array_ptr_1d_push(out, v);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ JL_DLLEXPORT jl_array_t *jl_find_free_typevars(jl_value_t *v)
// test whether a type has vars bound by the given environment
static int jl_has_bound_typevars(jl_value_t *v, jl_typeenv_t *env) JL_NOTSAFEPOINT
{
if (jl_typeis(v, jl_tvar_type))
if (jl_is_typevar(v))
return typeenv_has(env, (jl_tvar_t*)v);
if (jl_is_uniontype(v))
return jl_has_bound_typevars(((jl_uniontype_t*)v)->a, env) ||
Expand Down

0 comments on commit 0156c3d

Please sign in to comment.