julia
52e14ccc - Don't create a type parameter in the closure for captured @nospecialize arguments (#58426)

Commit
220 days ago
Don't create a type parameter in the closure for captured @nospecialize arguments (#58426) When we capture a variable without boxing, we always generate a type parameter for the closure. This probably isn't what the user wants if the captured variable is an argument marked `@nospecialize`. Before: ``` julia> K(@nospecialize(x)) = @nospecialize(y) -> x K (generic function with 1 method) julia> f, g = K(1), K("a") (var"#K##0#K##1"{Int64}(1), var"#K##0#K##1"{String}("a")) julia> f(2), g(2) (1, "a") julia> methods(f)[1].specializations svec(MethodInstance for (::var"#K##0#K##1"{Int64})(::Any), MethodInstance for (::var"#K##0#K##1"{String})(::Any), nothing, nothing, nothing, nothing, nothing) julia> fieldtypes(typeof(f)), fieldtypes(typeof(g)) ((Int64,), (String,)) ``` After: ``` julia> K(@nospecialize(x)) = @nospecialize(y) -> x K (generic function with 1 method) julia> f, g = K(1), K("a") (var"#K##0#K##1"(1), var"#K##0#K##1"("a")) julia> f(2), g(2) (1, "a") julia> methods(f)[1].specializations MethodInstance for (::var"#K##0#K##1")(::Any) julia> fieldtypes(typeof(f)), fieldtypes(typeof(g)) ((Any,), (Any,)) ```
Author
Parents
Loading