Skip to content

Commit

Permalink
Make apply_type_nothrow robust against TypeVars in upper bounds (#…
Browse files Browse the repository at this point in the history
…49863)

For types like `Foo{S, T<:S}`, `apply_type_nothrow` could in some
situations check whether the argument is a subtype of the upper bound of
`T`, i.e. `S`, but subtyping agaist a plain `TypeVar` would fail.
Instead return `false` in this case.

Fixes #49785.

(cherry picked from commit 1acec74)
  • Loading branch information
KristofferC committed Jun 27, 2023
1 parent 64b555f commit 118915f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
}
// if some normalization might be needed, do that now
// it is probably okay to mutate iparams, and we only store globally rooted objects here
if (check && cacheable) {
if (cacheable) {
size_t i;
for (i = 0; i < ntp; i++) {
jl_value_t *pi = iparams[i];
Expand Down Expand Up @@ -1678,7 +1678,7 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
}

// try to simplify some type parameters
if (check && tn != jl_type_typename) {
if (tn != jl_type_typename) {
size_t i;
int changed = 0;
if (istuple) // normalization might change Tuple's, but not other types's, cacheable status
Expand Down

0 comments on commit 118915f

Please sign in to comment.