Skip to content

Commit 5a8bdbf

Browse files
committed
Rewrite subtype_tuple to fix extra cases
1 parent 17e503e commit 5a8bdbf

File tree

4 files changed

+313
-137
lines changed

4 files changed

+313
-137
lines changed

base/compiler/typelimits.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec
9292
return t # easy case
9393
elseif isa(t, DataType) && isempty(t.parameters)
9494
return t # fast path: unparameterized are always simple
95-
elseif isa(unwrap_unionall(t), DataType) && isa(c, Type) && c !== Union{} && c <: t
96-
return t # t is already wider than the comparison in the type lattice
97-
elseif is_derived_type_from_any(unwrap_unionall(t), sources, depth)
98-
return t # t isn't something new
95+
else
96+
ut = unwrap_unionall(t)
97+
if isa(ut, DataType) && ut.name !== unwrap_unionall(Vararg).name && isa(c, Type) && c !== Union{} && c <: t
98+
return t # t is already wider than the comparison in the type lattice
99+
elseif is_derived_type_from_any(ut, sources, depth)
100+
return t # t isn't something new
101+
end
99102
end
100103
# peel off (and ignore) wrappers - they contribute no useful information, so we don't need to consider their size
101104
# first attempt to turn `c` into a type that contributes meaningful information

src/jltypes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,10 +1085,19 @@ static jl_value_t *inst_datatype_inner(jl_datatype_t *dt, jl_svec_t *p, jl_value
10851085
continue;
10861086
if (jl_is_datatype(pi))
10871087
continue;
1088+
if (jl_is_vararg_type(pi)) {
1089+
pi = jl_unwrap_vararg(pi);
1090+
if (jl_has_free_typevars(pi))
1091+
continue;
1092+
}
10881093
// normalize types equal to wrappers (prepare for wrapper_id)
10891094
jl_value_t *tw = extract_wrapper(pi);
10901095
if (tw && tw != pi && (tn != jl_type_typename || jl_typeof(pi) == jl_typeof(tw)) &&
10911096
jl_types_equal(pi, tw)) {
1097+
if (jl_is_vararg_type(iparams[i])) {
1098+
tw = jl_wrap_vararg(tw, jl_tparam1(jl_unwrap_unionall(iparams[i])));
1099+
tw = jl_rewrap_unionall(tw, iparams[i]);
1100+
}
10921101
iparams[i] = tw;
10931102
if (p) jl_gc_wb(p, tw);
10941103
}

0 commit comments

Comments
 (0)