From 067e6acaf1e9165de717419ab166d88bc9488871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Mon, 17 Jul 2023 23:00:32 +0200 Subject: [PATCH] Extensions do not commit piracy against base package --- src/Aqua.jl | 2 ++ src/piracy.jl | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/Aqua.jl b/src/Aqua.jl index 2f203016..fcc359ba 100644 --- a/src/Aqua.jl +++ b/src/Aqua.jl @@ -4,6 +4,8 @@ using Base: PkgId, UUID using Pkg: Pkg, TOML using Test +const JULIA_HAS_EXTENSIONS = isdefined(Base, :get_extension) # introduced in v1.9 + try findnext('a', "a", 1) catch diff --git a/src/piracy.jl b/src/piracy.jl index e29018bf..34e53dd2 100644 --- a/src/piracy.jl +++ b/src/piracy.jl @@ -1,5 +1,7 @@ module Piracy +using Aqua: JULIA_HAS_EXTENSIONS + if VERSION >= v"1.6-" using Test: is_in_mods else @@ -160,6 +162,11 @@ end function is_pirate(meth::Method; treat_as_own = Union{Function,Type}[]) method_pkg = Base.PkgId(meth.module) + # Package extensions behave as the package itself + @static if JULIA_HAS_EXTENSIONS + method_pkg = get(Base.EXT_PRIMED, method_pkg, method_pkg) + end + signature = Base.unwrap_unionall(meth.sig) # the first parameter in the signature is the function type, and it