@@ -34,7 +34,7 @@ function signature(m::Method)
3434
3535 def[:args ] = arguments (m)
3636 def[:whereparams ] = where_parameters (m)
37- def[:params ] = parameters (m)
37+ def[:params ] = type_parameters (m)
3838 def[:kwargs ] = kwargs (m)
3939
4040 return Dict (k => v for (k, v) in def if v != = nothing ) # filter out nonfields.
@@ -52,10 +52,10 @@ function argument_names(m::Method)
5252 return arg_names
5353end
5454
55-
56- function argument_types (m :: Method )
55+ argument_types (m :: Method ) = argument_types (m . sig)
56+ function argument_types (sig )
5757 # First parameter of `sig` is the type of the function itself
58- return parameters (m . sig)[2 : end ]
58+ return parameters (sig)[2 : end ]
5959end
6060
6161name_of_type (x) = x
@@ -74,7 +74,10 @@ function name_of_type(x::UnionAll)
7474 whereparam = where_parameters (x. var)
7575 return :($ name where $ whereparam)
7676end
77-
77+ function name_of_type (x:: Union )
78+ parameter_names = name_of_type .(Base. uniontypes (x))
79+ return :(Union{$ (parameter_names... )})
80+ end
7881
7982function arguments (m:: Method )
8083 arg_names = argument_names (m)
@@ -96,28 +99,28 @@ function where_parameters(x::TypeVar)
9699 if x. lb === Union{} && x. ub === Any
97100 return x. name
98101 elseif x. lb === Union{}
99- return :($ (x. name) <: $ (Symbol (x. ub)))
102+ return :($ (x. name) <: $ (name_of_type (x. ub)))
100103 elseif x. ub === Any
101- return :($ (x. name) >: $ (Symbol (x. lb)))
104+ return :($ (x. name) >: $ (name_of_type (x. lb)))
102105 else
103- return :($ (Symbol (x. lb)) <: $ (x. name) <: $ (Symbol (x. ub)))
106+ return :($ (name_of_type (x. lb)) <: $ (x. name) <: $ (name_of_type (x. ub)))
104107 end
105108end
106109
107- function where_parameters (m:: Method )
108- m . sig isa UnionAll || return nothing
109-
110+ where_parameters (m:: Method ) = where_parameters (m . sig )
111+ where_parameters ( sig) = nothing
112+ function where_parameters (sig :: UnionAll )
110113 whereparams = []
111- sig = m. sig
112114 while sig isa UnionAll
113115 push! (whereparams, where_parameters (sig. var))
114116 sig = sig. body
115117 end
116118 return whereparams
117119end
118120
119- function parameters (m:: Method )
120- typeof_type = first (parameters (m. sig)) # will be e.g Type{Foo{P}} if it has any parameters
121+ type_parameters (m:: Method ) = type_parameters (m. sig)
122+ function type_parameters (sig)
123+ typeof_type = first (parameters (sig)) # will be e.g Type{Foo{P}} if it has any parameters
121124 typeof_type <: Type{<:Any} || return nothing
122125
123126 function_type = first (parameters (typeof_type)) # will be e.g. Foo{P}
0 commit comments