Skip to content

Commit 51d352d

Browse files
committed
Make Base.get_extension private to prevent user mistakes
Added in #58108 without valid justification: something simply being documented in the manual is never any allowable argument for making something public. Being public is confusing users, since all of the other related infrastructure is also declared private (project files, `loaded_modules_array`, `PkgId`, `require`, etc.). Some of those do have legit uses in reflection testing, but we don't currently have a representation for this sort of private-except-reflection in most places (other than `Core.IR`). However is not allowed for packages to call `Base.get_extension`, since it requires accessing private implementation details of the target package to construct the arguments, and can run afoul of various implementation rules (world ages, module identity, precompile file consistency) that can lead to buggy execution. The correct way to use this functionality is with dispatch. Loosely: ```julia module Main function get_extension end end module MainPkgExt # extension module in Main using Other Main.get_extension(args...) = Other.call(args...) end ```
1 parent 040f6cd commit 51d352d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

base/loading.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,9 @@ end
16431643
"""
16441644
get_extension(parent::Module, extension::Symbol)
16451645
1646-
Return the module for `extension` of `parent` or return `nothing` if the extension is not loaded.
1646+
Return the module for `extension` relative to `parent` or return `nothing` if the extension is not loaded.
1647+
This function is private, since the arguments to it are private implementation details.
1648+
It is provided mainly for testing and reflection purposes.
16471649
"""
16481650
get_extension(parent::Module, ext::Symbol) = get_extension(PkgId(parent), ext)
16491651
function get_extension(parentid::PkgId, ext::Symbol)

base/public.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public
5454
active_project,
5555

5656
# Reflection and introspection
57-
get_extension,
5857
isambiguous,
5958
isexpr,
6059
isidentifier,

0 commit comments

Comments
 (0)