Skip to content

Commit f731c38

Browse files
authored
ensure invoke kwargs work on Types (#44464)
Fix #44227
1 parent c591bf2 commit f731c38

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/builtins.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
12861286
if (nt < jl_page_size/sizeof(jl_value_t*)) {
12871287
jl_value_t **types = (jl_value_t**)alloca(nt*sizeof(jl_value_t*));
12881288
types[0] = (jl_value_t*)jl_namedtuple_type;
1289-
types[1] = jl_typeof(func);
1289+
types[1] = jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func);
12901290
for (i = 2; i < nt; i++)
12911291
types[i] = jl_tparam(argtypes, i - 2);
12921292
argtypes = (jl_value_t*)jl_apply_tuple_type_v(types, nt);
@@ -1295,7 +1295,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
12951295
jl_svec_t *types = jl_alloc_svec_uninit(nt);
12961296
JL_GC_PUSH1(&types);
12971297
jl_svecset(types, 0, jl_namedtuple_type);
1298-
jl_svecset(types, 1, jl_typeof(func));
1298+
jl_svecset(types, 1, jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func));
12991299
for (i = 2; i < nt; i++)
13001300
jl_svecset(types, i, jl_tparam(argtypes, i - 2));
13011301
argtypes = (jl_value_t*)jl_apply_tuple_type(types);

test/core.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,12 @@ let
15241524
@test invoke(i2169, Tuple{Array}, Int8[1]) === Int8(-128)
15251525
end
15261526

1527+
# issue #44227
1528+
struct F{T} end
1529+
F{Int32}(; y=1) = 1
1530+
F{Int64}(; y=1) = invoke(F{Int32}, Tuple{}; y)
1531+
@test F{Int64}() === 1
1532+
15271533
# issue #2365
15281534
mutable struct B2365{T}
15291535
v::Union{T, Nothing}

0 commit comments

Comments
 (0)