You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started working on this but haven't quite nailed it down yet. Here's my start if anyone else wants to have a go:
diff --git a/src/Compat.jl b/src/Compat.jl
index c0c82d4..3007fab 100644
--- a/src/Compat.jl+++ b/src/Compat.jl@@ -662,6 +662,27 @@ module Sys
end
end
+if VERSION < v"0.7.0-DEV.969"+ # If any type annotations are provided, we'll just ignore them for now+ macro nospecialize(ex)+ if isa(ex, Symbol) # @nospecialize(x)+ Expr(:(::), quot(ex), :ANY)+ elseif ex.head == :(=) && isa(ex.args[1], Symbol) # @nospecialize(x=1)+ Expr(:(=), Expr(:(::), quot(ex.args[1]), :ANY), quot(ex.args[2]))+ elseif ex.head == :(=) && ex.args[1].head == :(::) # @nospecialize(x::T=1)+ Expr(:(=), Expr(:(::), quot(ex.args[1].args[1]), :ANY), quot(ex.args[1].args[2]))+ elseif ex.head == :(...) && isa(ex.args[1], Symbol) # @nospecialize(x...)+ Expr(:(...), Expr(:(::), quot(ex.args[1]), :ANY))+ elseif ex.head == :(...) && ex.args[1].head == :(::) # @nospecialize(x::T...)+ Expr(:(...), Expr(:(::), quot(ex.args[1].args[1]), :ANY))+ else+ error("improper use of @nospecialize")+ end+ end+else+ import Base: @nospecialize+end+
include("deprecated.jl")
end # module Compat
It basically just takes the @nospecialize annotation for a function argument and turns it into an ::ANY annotation on the argument.
The quoting here isn't working quite right, since, for example, the returned expression from @nospecialize(x) is actually :x::Main.ANY as the above stands. And we can't use esc here instead, since that produces Main.x::Main.ANY, which is wrong in the context of specifying a function signature.
The text was updated successfully, but these errors were encountered:
I started working on this but haven't quite nailed it down yet. Here's my start if anyone else wants to have a go:
It basically just takes the
@nospecialize
annotation for a function argument and turns it into an::ANY
annotation on the argument.The quoting here isn't working quite right, since, for example, the returned expression from
@nospecialize(x)
is actually:x::Main.ANY
as the above stands. And we can't useesc
here instead, since that producesMain.x::Main.ANY
, which is wrong in the context of specifying a function signature.The text was updated successfully, but these errors were encountered: