Skip to content

Commit

Permalink
Fix getobj
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jun 19, 2023
1 parent 03b678b commit 6cb4303
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ambiguities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.",
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/piracy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cb4303

Please sign in to comment.