Skip to content

Commit

Permalink
Make Core.TypeofUnion use the type method table (#55188)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
vtjnash authored and KristofferC committed Jul 23, 2024
1 parent 6844898 commit b39fd85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3518,8 +3518,11 @@ void jl_init_types(void) JL_GC_DISABLED
jl_emptysvec, 0, 0, 4);

// all Kinds share the Type method table (not the nonfunction one)
jl_unionall_type->name->mt = jl_uniontype_type->name->mt = jl_datatype_type->name->mt =
jl_type_type_mt;
jl_unionall_type->name->mt =
jl_uniontype_type->name->mt =
jl_datatype_type->name->mt =
jl_typeofbottom_type->name->mt =
jl_type_type_mt;

jl_intrinsic_type = jl_new_primitivetype((jl_value_t*)jl_symbol("IntrinsicFunction"), core,
jl_builtin_type, jl_emptysvec, 32);
Expand Down
2 changes: 2 additions & 0 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1193,3 +1193,5 @@ end
@test Base.isexported(Mod52812, :b)
@test Base.ispublic(Mod52812, :a)
@test Base.ispublic(Mod52812, :b)

@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 comments on commit b39fd85

Please sign in to comment.