@@ -27,13 +27,23 @@ with [`CodeTracking.definition`](https://github.com/timholy/CodeTracking.jl).
27
27
The dictionary of components returned by `signature` match those returned by
28
28
[`splitdef`](@ref) and include all that are required by [`combinedef`](@ref), except for
29
29
the `:body` component.
30
+
31
+ # keywords
32
+
33
+ - `extra_hygiene=false`: if set to `true` this forces name-hygiene on the `TypeVar`s in
34
+ `UnionAll`s, regenerating each with a unique name via `gensym`. This shouldn't actually
35
+ be required as they are scoped such that they are not supposed to leak. However, there is
36
+ a long-standing [julia bug](https://github.com/JuliaLang/julia/issues/39876) that means
37
+ they do leak if they clash with function type-vars.
30
38
"""
31
- function signature (m:: Method )
39
+ function signature (m:: Method ; extra_hygiene= false )
40
+ sig = extra_hygiene ? _truly_rename_unionall (m. sig) : m. sig
41
+
32
42
def = Dict {Symbol, Any} ()
33
43
def[:name ] = m. name
34
44
35
- def[:args ] = arguments (m)
36
- def[:whereparams ] = where_parameters (m )
45
+ def[:args ] = arguments (m, sig )
46
+ def[:whereparams ] = where_parameters (sig )
37
47
def[:params ] = type_parameters (m)
38
48
def[:kwargs ] = kwargs (m)
39
49
@@ -168,9 +178,9 @@ function name_of_type(x::Union)
168
178
return :(Union{$ (parameter_names... )})
169
179
end
170
180
171
- function arguments (m:: Method )
181
+ function arguments (m:: Method , sig = m . sig )
172
182
arg_names = argument_names (m)
173
- arg_types = argument_types (m )
183
+ arg_types = argument_types (sig )
174
184
map (arg_names, arg_types) do name, type
175
185
has_name = name != = Symbol (" #unused#" )
176
186
type_name = name_of_type (type)
0 commit comments