Skip to content

Commit

Permalink
fix #22842, dispatch confusion with Type{T} vs. typeof(T) (#23831)
Browse files Browse the repository at this point in the history
(cherry picked from commit f4619d0)
  • Loading branch information
JeffBezanson authored and ararslan committed Nov 14, 2017
1 parent 6b08ccd commit 9de323f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,13 @@ static int typekey_eq(jl_datatype_t *tt, jl_value_t **key, size_t n)
}
for(j=0; j < n; j++) {
jl_value_t *kj = key[j], *tj = jl_svecref(tt->parameters,j);
if (tj != kj && !jl_types_equal(tj, kj))
return 0;
if (tj != kj) {
// require exact same Type{T}. see e.g. issue #22842
if (jl_is_type_type(tj) || jl_is_type_type(kj))
return 0;
if (!jl_types_equal(tj, kj))
return 0;
}
}
return 1;
}
Expand Down
6 changes: 6 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ let
@test_throws MethodError foor(StridedArray)
end

# issue #22842
f22842(x::UnionAll) = UnionAll
f22842(x::DataType) = length(x.parameters)
@test f22842(Tuple{Vararg{Int64,N} where N}) == 1
@test f22842(Tuple{Vararg{Int64,N}} where N) === UnionAll

# issue #1153
mutable struct SI{m, s, kg}
value::AbstractFloat
Expand Down

0 comments on commit 9de323f

Please sign in to comment.