Skip to content

Commit 0ba707d

Browse files
committed
Drop compat code for at-nospecialize (from #385 and #409)
1 parent f16e3e5 commit 0ba707d

File tree

4 files changed

+17
-45
lines changed

4 files changed

+17
-45
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ Currently, the `@compat` macro supports the following syntaxes:
368368

369369
## New macros
370370

371-
* `@nospecialize` has been added ([#22666]).
372-
373371
* The logging macros `@error`, `@warn`, `@info` and `@debug` can be used as
374372
`Compat.@error`, `Compat.@warn`, `Compat.@info` and `Compat.@debug` on Julia 0.6 ([#24490]).
375373
Note that the behavior do not mirror the logging macros in Julia 0.7, instead on Julia 0.6:

src/Compat.jl

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,6 @@ import Sockets
77

88
include("compatmacro.jl")
99

10-
@static if !isdefined(Base, Symbol("@nospecialize"))
11-
# 0.7
12-
macro nospecialize(arg)
13-
if isa(arg, Symbol)
14-
# @nospecialize(arg)
15-
return :($(esc(arg))::ANY)
16-
elseif isa(arg, Expr) && arg.head == :(::)
17-
# @nospecialize(arg::typ)
18-
# unsupported: needs ::ANY which would change dispatch as determined by ::typ
19-
elseif isa(arg, Expr) && arg.head == :(=)
20-
# @nospecialize(arg=val)
21-
arg, val = arg.args
22-
if isa(arg, Expr) && arg.head == :(::)
23-
# @nospecialize(arg::typ=val)
24-
# unsupported (see above), but generate a kw arg
25-
arg, typ = arg.args
26-
return Expr(:kw, :($(esc(arg))::$(esc(typ))), esc(val))
27-
else
28-
return Expr(:kw, :($(esc(arg))::ANY), esc(val))
29-
end
30-
end
31-
return esc(arg)
32-
end
33-
export @nospecialize
34-
end
35-
3610
# https://github.com/JuliaLang/julia/pull/22064
3711
@static if !isdefined(Base, Symbol("@__MODULE__"))
3812
# 0.7

test/old.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,20 @@ end
2323
@test stdout === STDOUT
2424
@test stderr === STDERR
2525
end
26+
27+
# @nospecialize
28+
# 0.7
29+
no_specialize(@nospecialize(x)) = sin(1)
30+
no_specialize(@nospecialize(x::Integer)) = sin(2)
31+
@test no_specialize(1.0) == sin(1)
32+
@test no_specialize(1) == sin(2)
33+
no_specialize_kw1(@nospecialize(x=0)) = sin(1)
34+
no_specialize_kw1(@nospecialize(x::Integer)) = sin(2)
35+
@test no_specialize_kw1(1.0) == sin(1)
36+
@test no_specialize_kw1(1) == sin(2)
37+
@test no_specialize_kw1() == sin(2)
38+
no_specialize_kw2(@nospecialize(x)) = sin(1)
39+
no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2)
40+
@test no_specialize_kw2(1.0) == sin(1)
41+
@test no_specialize_kw2(1) == sin(2)
42+
@test no_specialize_kw2() == sin(2)

test/runtests.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,6 @@ end
265265
@test @inferred(ntuple(x->x, Val(0))) == ()
266266
@test @inferred(ntuple(x->x, Val(5))) == (1,2,3,4,5)
267267

268-
# @nospecialize
269-
# 0.7
270-
no_specialize(@nospecialize(x)) = sin(1)
271-
no_specialize(@nospecialize(x::Integer)) = sin(2)
272-
@test no_specialize(1.0) == sin(1)
273-
@test no_specialize(1) == sin(2)
274-
no_specialize_kw1(@nospecialize(x=0)) = sin(1)
275-
no_specialize_kw1(@nospecialize(x::Integer)) = sin(2)
276-
@test no_specialize_kw1(1.0) == sin(1)
277-
@test no_specialize_kw1(1) == sin(2)
278-
@test no_specialize_kw1() == sin(2)
279-
no_specialize_kw2(@nospecialize(x)) = sin(1)
280-
no_specialize_kw2(@nospecialize(x::Integer=0)) = sin(2)
281-
@test no_specialize_kw2(1.0) == sin(1)
282-
@test no_specialize_kw2(1) == sin(2)
283-
@test no_specialize_kw2() == sin(2)
284-
285268
# 0.7
286269
@test read(IOBuffer("aaaa"), String) == "aaaa"
287270
@test occursin("read(@__FILE__, String)", read(@__FILE__, String))

0 commit comments

Comments
 (0)