Skip to content

Commit

Permalink
Merge pull request #30 from cscherrer/dev
Browse files Browse the repository at this point in the history
update instance_type
  • Loading branch information
cscherrer authored Apr 26, 2022
2 parents c08d836 + d640d9b commit 65c33f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "KeywordCalls"
uuid = "4d827475-d3e4-43d6-abe3-9688362ede9f"
authors = ["Chad Scherrer <[email protected]> and contributors"]
version = "0.2.3"
version = "0.2.4"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
14 changes: 4 additions & 10 deletions src/KeywordCalls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ function _kwcall(__module__, ex)

alias = KeywordCalls.alias
_sort = KeywordCalls._sort
instance_type = KeywordCalls.instance_type

inst = instance_type(f)
inst = Core.Typeof(f)
q = quote
function KeywordCalls._call_in_default_order(::$inst, nt::NamedTuple{($(sorted_argnames...),)})
return $f_esc(NamedTuple{($(argnames...),)}(nt))
Expand Down Expand Up @@ -129,10 +128,10 @@ function _kwstruct(__module__, ex)
# But we can fake it by creating a `build` method that's defined iff the
# constructor has the corresponding method. Then we can check for presence
# of the `build` method and know whether the constructor method is defined.
if !static_hasmethod(build, Tuple{instance_type(f), Tuple{NamedTuple{((args...),)}}})
if !static_hasmethod(build, Tuple{Core.Typeof(f), Tuple{NamedTuple{((args...),)}}})
argnames = QuoteNode.(args)

inst = instance_type(f)
inst = Core.Typeof(f)
new_method = quote
$f_esc(nt::NamedTuple{($(argnames...),),T}) where {T} = $f_esc{($(argnames...),), T}(nt)
KeywordCalls.build(::$inst, ::NamedTuple{($(argnames...),),T}) where {T} = true
Expand Down Expand Up @@ -171,7 +170,7 @@ function _kwalias(__module__, fsym, aliasmap)
(a,b) = QuoteNode.(pair.args[2:3])


inst = instance_type(f)
inst = Core.Typeof(f)
newmethod = quote
KeywordCalls.alias(::$inst, ::Val{$a}) = $b
end
Expand All @@ -181,9 +180,4 @@ function _kwalias(__module__, fsym, aliasmap)
return q
end

# See https://github.com/cscherrer/KeywordCalls.jl/issues/22
@inline instance_type(f::F) where {F<:Function} = F
@inline instance_type(f::UnionAll) = Type{f}


end # module

2 comments on commit 65c33f8

@cscherrer
Copy link
Owner Author

Choose a reason for hiding this comment

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

@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/59162

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.2.4 -m "<description of version>" 65c33f84af5c1c6ee6a74d5e2848c6ab39af78f8
git push origin v0.2.4

Please sign in to comment.