Skip to content

Commit b3c4075

Browse files
vtjnashKristofferC
authored andcommitted
ensure invoke kwargs work on Types (#44464)
Fix #44227 (cherry picked from commit f731c38)
1 parent 6918fc4 commit b3c4075

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
@@ -1243,7 +1243,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
12431243
if (nt < jl_page_size/sizeof(jl_value_t*)) {
12441244
jl_value_t **types = (jl_value_t**)alloca(nt*sizeof(jl_value_t*));
12451245
types[0] = (jl_value_t*)jl_namedtuple_type;
1246-
types[1] = jl_typeof(func);
1246+
types[1] = jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func);
12471247
for (i = 2; i < nt; i++)
12481248
types[i] = jl_tparam(argtypes, i - 2);
12491249
argtypes = (jl_value_t*)jl_apply_tuple_type_v(types, nt);
@@ -1252,7 +1252,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
12521252
jl_svec_t *types = jl_alloc_svec_uninit(nt);
12531253
JL_GC_PUSH1(&types);
12541254
jl_svecset(types, 0, jl_namedtuple_type);
1255-
jl_svecset(types, 1, jl_typeof(func));
1255+
jl_svecset(types, 1, jl_is_type(func) ? (jl_value_t*)jl_wrap_Type(func) : jl_typeof(func));
12561256
for (i = 2; i < nt; i++)
12571257
jl_svecset(types, i, jl_tparam(argtypes, i - 2));
12581258
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
@@ -1441,6 +1441,12 @@ let
14411441
@test invoke(i2169, Tuple{Array}, Int8[1]) === Int8(-128)
14421442
end
14431443

1444+
# issue #44227
1445+
struct F{T} end
1446+
F{Int32}(; y=1) = 1
1447+
F{Int64}(; y=1) = invoke(F{Int32}, Tuple{}; y)
1448+
@test F{Int64}() === 1
1449+
14441450
# issue #2365
14451451
mutable struct B2365{T}
14461452
v::Union{T, Nothing}

0 commit comments

Comments
 (0)