Skip to content

Commit 1d840d7

Browse files
authored
Merge pull request #39548 from JuliaLang/backports-release-1.6
Another backport for 1.6-RC1
2 parents d8f8b84 + 1dacf66 commit 1d840d7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/subtype.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,17 +1788,19 @@ static int obvious_subtype(jl_value_t *x, jl_value_t *y, jl_value_t *y0, int *su
17881788
*subtype = 0;
17891789
return 1;
17901790
}
1791-
if (jl_is_type_type(a1) && jl_is_type(jl_tparam0(a1))) {
1792-
a1 = jl_typeof(jl_tparam0(a1));
1791+
jl_value_t *a1u = jl_unwrap_unionall(a1);
1792+
if (jl_is_type_type(a1u) && jl_is_type(jl_tparam0(a1u))) {
1793+
a1 = jl_typeof(jl_tparam0(a1u));
17931794
}
17941795
for (; i < nparams_expanded_x; i++) {
17951796
jl_value_t *a = (vx != JL_VARARG_NONE && i >= npx - 1) ? vxt : jl_tparam(x, i);
17961797
if (i > npy && jl_is_typevar(b)) { // i == npy implies a == a1
17971798
// diagonal rule: all the later parameters are also constrained to be type-equal to the first
17981799
jl_value_t *a2 = a;
1799-
if (jl_is_type_type(a) && jl_is_type(jl_tparam0(a))) {
1800+
jl_value_t *au = jl_unwrap_unionall(a);
1801+
if (jl_is_type_type(au) && jl_is_type(jl_tparam0(au))) {
18001802
// if a is exactly Type{T}, then use the concrete typeof(T) instead here
1801-
a2 = jl_typeof(jl_tparam0(a));
1803+
a2 = jl_typeof(jl_tparam0(au));
18021804
}
18031805
if (!obviously_egal(a1, a2)) {
18041806
if (obvious_subtype(a2, a1, y0, subtype)) {

test/subtype.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,3 +1861,7 @@ f39218(::T, ::T) where {T<:AB39218} = false
18611861
g39218(a, b) = (@nospecialize; if a isa AB39218 && b isa AB39218; f39218(a, b); end;)
18621862
@test g39218(A39218(), A39218()) === false
18631863
@test_throws MethodError g39218(A39218(), B39218())
1864+
1865+
# issue #39521
1866+
@test Tuple{Type{Tuple{A}} where A, DataType, DataType} <: Tuple{Vararg{B}} where B
1867+
@test Tuple{DataType, Type{Tuple{A}} where A, DataType} <: Tuple{Vararg{B}} where B

0 commit comments

Comments
 (0)