Skip to content

Commit d68befd

Browse files
authored
Make Core.TypeofUnion use the type method table (#55188)
Ensures that adding or examining the methods of Type{Union{}} in the method table returns the correct results. Fixes #55187
1 parent fe207c5 commit d68befd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/jltypes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3581,8 +3581,11 @@ void jl_init_types(void) JL_GC_DISABLED
35813581
jl_emptysvec, 0, 0, 4);
35823582

35833583
// all Kinds share the Type method table (not the nonfunction one)
3584-
jl_unionall_type->name->mt = jl_uniontype_type->name->mt = jl_datatype_type->name->mt =
3585-
jl_type_type_mt;
3584+
jl_unionall_type->name->mt =
3585+
jl_uniontype_type->name->mt =
3586+
jl_datatype_type->name->mt =
3587+
jl_typeofbottom_type->name->mt =
3588+
jl_type_type_mt;
35863589

35873590
jl_intrinsic_type = jl_new_primitivetype((jl_value_t*)jl_symbol("IntrinsicFunction"), core,
35883591
jl_builtin_type, jl_emptysvec, 32);

test/reflection.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,3 +1296,5 @@ end
12961296

12971297
@test Base.infer_return_type(code_lowered, (Any,)) == Vector{Core.CodeInfo}
12981298
@test Base.infer_return_type(code_lowered, (Any,Any)) == Vector{Core.CodeInfo}
1299+
1300+
@test methods(Union{}) == Any[m.method for m in Base._methods_by_ftype(Tuple{Core.TypeofBottom, Vararg}, 1, Base.get_world_counter())] # issue #55187

0 commit comments

Comments
 (0)