Skip to content

Commit b39fd85

Browse files
vtjnashKristofferC
authored andcommitted
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 (cherry picked from commit d68befd)
1 parent 6844898 commit b39fd85

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
@@ -3518,8 +3518,11 @@ void jl_init_types(void) JL_GC_DISABLED
35183518
jl_emptysvec, 0, 0, 4);
35193519

35203520
// all Kinds share the Type method table (not the nonfunction one)
3521-
jl_unionall_type->name->mt = jl_uniontype_type->name->mt = jl_datatype_type->name->mt =
3522-
jl_type_type_mt;
3521+
jl_unionall_type->name->mt =
3522+
jl_uniontype_type->name->mt =
3523+
jl_datatype_type->name->mt =
3524+
jl_typeofbottom_type->name->mt =
3525+
jl_type_type_mt;
35233526

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

test/reflection.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,3 +1193,5 @@ end
11931193
@test Base.isexported(Mod52812, :b)
11941194
@test Base.ispublic(Mod52812, :a)
11951195
@test Base.ispublic(Mod52812, :b)
1196+
1197+
@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)