Skip to content

Commit fa24848

Browse files
JeffBezansonararslan
authored andcommitted
fix #22908, typemap ordering of Union vs. Type{Union{...}}.
Ref #22909 (cherry picked from commit 7e37e5d)
1 parent a963a85 commit fa24848

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/typemap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ jl_typemap_entry_t *jl_typemap_insert(union jl_typemap_t *cache, jl_value_t *par
10451045
newrec->isleafsig = 0; // Type{} may have a higher priority than DataType
10461046
else if (decl == (jl_value_t*)jl_unionall_type)
10471047
newrec->isleafsig = 0; // Type{} may have a higher priority than UnionAll
1048+
else if (decl == (jl_value_t*)jl_uniontype_type)
1049+
newrec->isleafsig = 0; // Type{} may have a higher priority than Union
10481050
else if (jl_is_type_type(decl))
10491051
newrec->isleafsig = 0; // Type{} may need special processing to compute the match
10501052
else if (jl_is_vararg_type(decl))

test/specificity.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ let A = Tuple{T, Array{T, 1}} where T,
172172
@test args_morespecific(C, B)
173173
@test args_morespecific(C, A)
174174
end
175+
176+
# issue #22908
177+
f22908(::Union) = 2
178+
f22908(::Type{Union{Int, Float32}}) = 1
179+
@test f22908(Union{Int, Float32}) == 1

0 commit comments

Comments
 (0)