Skip to content

Commit

Permalink
ensure invoke kwargs work on Types
Browse files Browse the repository at this point in the history
Fix #44227
  • Loading branch information
vtjnash committed Mar 8, 2022
1 parent dc45d77 commit 0bc3ef1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
if (nt < jl_page_size/sizeof(jl_value_t*)) {
jl_value_t **types = (jl_value_t**)alloca(nt*sizeof(jl_value_t*));
types[0] = (jl_value_t*)jl_namedtuple_type;
types[1] = jl_typeof(func);
types[1] = jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func);
for (i = 2; i < nt; i++)
types[i] = jl_tparam(argtypes, i - 2);
argtypes = (jl_value_t*)jl_apply_tuple_type_v(types, nt);
Expand All @@ -1295,7 +1295,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
jl_svec_t *types = jl_alloc_svec_uninit(nt);
JL_GC_PUSH1(&types);
jl_svecset(types, 0, jl_namedtuple_type);
jl_svecset(types, 1, jl_typeof(func));
jl_svecset(types, 1, jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func));
for (i = 2; i < nt; i++)
jl_svecset(types, i, jl_tparam(argtypes, i - 2));
argtypes = (jl_value_t*)jl_apply_tuple_type(types);
Expand Down
6 changes: 6 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,12 @@ let
@test invoke(i2169, Tuple{Array}, Int8[1]) === Int8(-128)
end

# issue #44227
struct F{T} end
F{Int32}(; y=1) = 1
F{Int64}(; y=1) = invoke(F{Int32}, Tuple{}; y)
@test F{Int64}() === 1

# issue #2365
mutable struct B2365{T}
v::Union{T, Nothing}
Expand Down

0 comments on commit 0bc3ef1

Please sign in to comment.