Skip to content

Commit

Permalink
Enable seperatable subtyping for equality check.
Browse files Browse the repository at this point in the history
  • Loading branch information
N5N3 committed Apr 5, 2023
1 parent bd1a664 commit 280f999
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/subtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,10 @@ static int local_forall_exists_subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t
{
int16_t oldRmore = e->Runions.more;
int sub;
int kindx = !jl_has_free_typevars(x);
int kindy = !jl_has_free_typevars(y);
if (kindx && kindy)
return jl_subtype(x, y);
if (may_contain_union_decision(y, e, NULL) && pick_union_decision(e, 1) == 0) {
jl_saved_unionstate_t oldRunions; push_unionstate(&oldRunions, &e->Runions);
e->Lunions.used = e->Runions.used = 0;
Expand All @@ -1581,6 +1585,8 @@ static int local_forall_exists_subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t
// Once limit_slow == 1, also skip it if
// 1) `forall_exists_subtype` return false
// 2) the left `Union` looks big
if (limit_slow == -1)
limit_slow = kindx || kindy;
if (noRmore || (limit_slow && (count > 3 || !sub)))
e->Runions.more = oldRmore;
}
Expand Down Expand Up @@ -1630,8 +1636,7 @@ static int forall_exists_equal(jl_value_t *x, jl_value_t *y, jl_stenv_t *e)

jl_saved_unionstate_t oldLunions; push_unionstate(&oldLunions, &e->Lunions);

int limit_slow = !jl_has_free_typevars(x) || !jl_has_free_typevars(y);
int sub = local_forall_exists_subtype(x, y, e, 2, limit_slow);
int sub = local_forall_exists_subtype(x, y, e, 2, -1);
if (sub) {
flip_offset(e);
sub = local_forall_exists_subtype(y, x, e, 0, 0);
Expand Down

0 comments on commit 280f999

Please sign in to comment.