Skip to content

Commit

Permalink
Add optional types to func_specializations(f[, tt])
Browse files Browse the repository at this point in the history
Also add `method_specializations(m)::Vector`
  • Loading branch information
NHDaly committed Oct 6, 2020
1 parent 3c4ba75 commit 91582a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LookingGlass"
uuid = "1fcbbee2-b350-4a01-aad8-439064dba09e"
authors = ["Nathan Daly"]
version = "0.3.0"
version = "0.3.1"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
13 changes: 10 additions & 3 deletions src/LookingGlass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro quot(e) QuoteNode(e) end
# ---------------------------------------------------------------------------

"""
func_specializations(f) -> Dict(MethodInstance => Method)
func_specializations(f[, tt]) -> Dict(MethodInstance => Method)
Return all the specializations (MethodInstances) of each method of the given function (or
callable object), if there are any.
Expand All @@ -57,10 +57,17 @@ function func_specializations end
func_specializations(f) =
Dict(mi => m
for m in methods(f).ms
for mi in _iterate_method_specializations(m)
for mi in _method_specializations(m)
)
func_specializations(f, tt) =
Dict(mi => m
for m in methods(f, tt).ms
for mi in _method_specializations(m)
)

method_specializations(m) = collect(_method_specializations(m))

function _iterate_method_specializations(m)
function _method_specializations(m::Method)
s = m.specializations
if VERSION > v"1.5-"
return (s[i] for i in 1:length(s) if isassigned(s, i))
Expand Down

4 comments on commit 91582a6

@NHDaly
Copy link
Owner Author

@NHDaly NHDaly commented on 91582a6 Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/22465

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 91582a67fd12a3b3d161d30c5499bdd94e11bfdf
git push origin v0.3.1

Also, note the warning: Version 0.3.1 skips over 0.3.0
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@NHDaly
Copy link
Owner Author

@NHDaly NHDaly commented on 91582a6 Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/23302

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 91582a67fd12a3b3d161d30c5499bdd94e11bfdf
git push origin v0.3.1

Please sign in to comment.