Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getobj for parameterized callable objects #142

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix getobj
lgoettgens committed Jun 19, 2023
commit ca16eb88eed4cc76a610a550ce5cde5932876a13
3 changes: 2 additions & 1 deletion src/ambiguities.jl
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ struct _NoValue end
# FIXME: This does not support non-singleton callables.
function getobj(m::Method)
ty = try
Base.tuple_type_head(m.sig)
fieldtype(m.sig, 1)
catch err
@error(
"Failed to obtain a function from `Method`.",
@@ -160,6 +160,7 @@ function getobj(m::Method)
# too much compared to what it is now. So, bailing out.
return _NoValue()
end
ty = Base.unwrap_unionall(ty)
try
return ty.instance # this should work for singletons (e.g., functions)
catch
5 changes: 1 addition & 4 deletions src/piracy.jl
Original file line number Diff line number Diff line change
@@ -144,10 +144,7 @@ end
function is_pirate(meth::Method)
method_pkg = Base.PkgId(meth.module)

signature = meth.sig
while signature isa UnionAll
signature = signature.body
end
signature = Base.unwrap_unionall(meth.sig)

# the first parameter in the signature is the function type, and it
# follows slightly other rules if it happens to be a Union type