Skip to content

Commit c3d3107

Browse files
committed
convert more Union(...) to Union{...} instances that escaped JuliaLang#11432
1 parent bb4eddc commit c3d3107

File tree

12 files changed

+48
-48
lines changed

12 files changed

+48
-48
lines changed

base/deprecated.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ type SharedMemSpec
611611
create :: Bool
612612
end
613613
export mmap_array
614-
function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union(IO,SharedMemSpec), offset::FileOffset)
614+
function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union{IO,SharedMemSpec}, offset::FileOffset)
615615
depwarn("`mmap_array` is deprecated, use `Mmap.mmap(io, Array{T,N}, dims, offset)` instead to return an mmapped-array", :mmap_array)
616616
if isa(s,SharedMemSpec)
617617
a = Mmap.Anonymous(s.name, s.readonly, s.create)

base/dft.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ for f in (:fft, :bfft, :ifft)
4646
@eval begin
4747
$f{T<:Real}(x::AbstractArray{T}, region=1:ndims(x)) = $f(complexfloat(x), region)
4848
$pf{T<:Real}(x::AbstractArray{T}, region; kws...) = $pf(complexfloat(x), region; kws...)
49-
$f{T<:Union(Integer,Rational)}(x::AbstractArray{Complex{T}}, region=1:ndims(x)) = $f(complexfloat(x), region)
50-
$pf{T<:Union(Integer,Rational)}(x::AbstractArray{Complex{T}}, region; kws...) = $pf(complexfloat(x), region; kws...)
49+
$f{T<:Union{Integer,Rational}}(x::AbstractArray{Complex{T}}, region=1:ndims(x)) = $f(complexfloat(x), region)
50+
$pf{T<:Union{Integer,Rational}}(x::AbstractArray{Complex{T}}, region; kws...) = $pf(complexfloat(x), region; kws...)
5151
end
5252
end
53-
rfft{T<:Union(Integer,Rational)}(x::AbstractArray{T}, region=1:ndims(x)) = rfft(float(x), region)
54-
plan_rfft{T<:Union(Integer,Rational)}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...)
53+
rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region=1:ndims(x)) = rfft(float(x), region)
54+
plan_rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...)
5555

5656
# only require implementation to provide *(::Plan{T}, ::Array{T})
5757
*{T}(p::Plan{T}, x::AbstractArray) = p * copy!(Array(T, size(x)), x)
@@ -138,7 +138,7 @@ end
138138
for f in (:brfft, :irfft)
139139
@eval begin
140140
$f{T<:Real}(x::AbstractArray{T}, d::Integer, region=1:ndims(x)) = $f(complexfloat(x), d, region)
141-
$f{T<:Union(Integer,Rational)}(x::AbstractArray{Complex{T}}, d::Integer, region=1:ndims(x)) = $f(complexfloat(x), d, region)
141+
$f{T<:Union{Integer,Rational}}(x::AbstractArray{Complex{T}}, d::Integer, region=1:ndims(x)) = $f(complexfloat(x), d, region)
142142
end
143143
end
144144

base/docs/helpdb.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2614,7 +2614,7 @@ rol
26142614
doc"""
26152615
```rst
26162616
::
2617-
Mmap.mmap(io::Union(IOStream,AbstractString,Mmap.AnonymousMmap)[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
2617+
Mmap.mmap(io::Union{IOStream,AbstractString,Mmap.AnonymousMmap}[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
26182618
Mmap.mmap(type::Type{Array{T,N}}, dims)
26192619
26202620
Create an ``Array`` whose values are linked to a file, using memory-mapping. This provides a convenient way of working with data too large to fit in the computer's memory.

base/fft/FFTW.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ end
6161

6262
# FFTW floating-point types:
6363

64-
typealias fftwNumber Union(Float64,Float32,Complex128,Complex64)
65-
typealias fftwReal Union(Float64,Float32)
66-
typealias fftwComplex Union(Complex128,Complex64)
67-
typealias fftwDouble Union(Float64,Complex128)
68-
typealias fftwSingle Union(Float32,Complex64)
69-
typealias fftwTypeDouble Union(Type{Float64},Type{Complex128})
70-
typealias fftwTypeSingle Union(Type{Float32},Type{Complex64})
64+
typealias fftwNumber Union{Float64,Float32,Complex128,Complex64}
65+
typealias fftwReal Union{Float64,Float32}
66+
typealias fftwComplex Union{Complex128,Complex64}
67+
typealias fftwDouble Union{Float64,Complex128}
68+
typealias fftwSingle Union{Float32,Complex64}
69+
typealias fftwTypeDouble Union{Type{Float64},Type{Complex128}}
70+
typealias fftwTypeSingle Union{Type{Float32},Type{Complex64}}
7171

7272
# For ESTIMATE plans, FFTW allows one to pass NULL for the array pointer,
7373
# since it is not written to. Hence, it is convenient to create an

base/floatfuncs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,4 @@ const ≈ = isapprox
176176
# default tolerance arguments
177177
rtoldefault{T<:AbstractFloat}(::Type{T}) = sqrt(eps(T))
178178
rtoldefault{T<:Real}(::Type{T}) = 0
179-
rtoldefault{T<:Number,S<:Number}(x::Union(T,Type{T}), y::Union(S,Type{S})) = rtoldefault(promote_type(real(T),real(S)))
179+
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = rtoldefault(promote_type(real(T),real(S)))

base/poll.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ function close(t::FDWatcher)
172172
close(t.watcher, r, w)
173173
end
174174

175-
function uvfinalize(uv::Union(FileMonitor, PollingFileWatcher))
175+
function uvfinalize(uv::Union{FileMonitor, PollingFileWatcher})
176176
disassociate_julia_struct(uv)
177177
close(uv)
178178
end
179179

180-
function close(t::Union(FileMonitor, PollingFileWatcher))
180+
function close(t::Union{FileMonitor, PollingFileWatcher})
181181
if t.handle != C_NULL
182182
ccall(:jl_close_uv, Void, (Ptr{Void},), t.handle)
183183
t.handle = C_NULL

base/sort.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ immutable InsertionSortAlg <: Algorithm end
195195
immutable QuickSortAlg <: Algorithm end
196196
immutable MergeSortAlg <: Algorithm end
197197

198-
immutable PartialQuickSort{T <: Union(Int,OrdinalRange)} <: Algorithm
198+
immutable PartialQuickSort{T <: Union{Int,OrdinalRange}} <: Algorithm
199199
k::T
200200
end
201201

@@ -406,11 +406,11 @@ sort(v::AbstractVector; kws...) = sort!(copy(v); kws...)
406406

407407
## selectperm: the permutation to sort the first k elements of an array ##
408408

409-
selectperm(v::AbstractVector, k::Union(Integer,OrdinalRange); kwargs...) =
409+
selectperm(v::AbstractVector, k::Union{Integer,OrdinalRange}; kwargs...) =
410410
selectperm!(Vector{eltype(k)}(length(v)), v, k; kwargs..., initialized=false)
411411

412412
function selectperm!{I<:Integer}(ix::AbstractVector{I}, v::AbstractVector,
413-
k::Union(Int, OrdinalRange);
413+
k::Union{Int, OrdinalRange};
414414
lt::Function=isless,
415415
by::Function=identity,
416416
rev::Bool=false,

doc/stdlib/io-network.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ Memory-mapped I/O
11451145

11461146
Create an ``IO``-like object for creating zeroed-out mmapped-memory that is not tied to a file for use in ``Mmap.mmap``. Used by ``SharedArray`` for creating shared memory arrays.
11471147

1148-
.. function:: Mmap.mmap(io::Union(IOStream,AbstractString,Mmap.AnonymousMmap)[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
1148+
.. function:: Mmap.mmap(io::Union{IOStream,AbstractString,Mmap.AnonymousMmap}[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
11491149

11501150
::
11511151
Mmap.mmap(type::Type{Array{T,N}}, dims)
@@ -1201,7 +1201,7 @@ Memory-mapped I/O
12011201
.. function:: Mmap.mmap(io, BitArray, [dims, offset])
12021202

12031203
::
1204-
Mmap.mmap(io::Union(IOStream,AbstractString,Mmap.AnonymousMmap)[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
1204+
Mmap.mmap(io::Union{IOStream,AbstractString,Mmap.AnonymousMmap}[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
12051205
Mmap.mmap(type::Type{Array{T,N}}, dims)
12061206

12071207
Create an ``Array`` whose values are linked to a file, using memory-mapping. This provides a convenient way of working with data too large to fit in the computer's memory.

examples/juliatypes.jl

+23-23
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type UnionAllT <: Ty
100100
var::Var
101101
T
102102
UnionAllT(v::Var, t) = new(v, t)
103-
UnionAllT(v::Var, t::Union(Type,Tuple)) = new(v, convert(Ty, t))
103+
UnionAllT(v::Var, t::Union{Type,Tuple}) = new(v, convert(Ty, t))
104104
end
105105

106106
function show(io::IO, x::UnionAllT)
@@ -313,7 +313,7 @@ function issub(a::Var, b::Var, env)
313313
end
314314
end
315315

316-
function var_lt(b::Var, a::Union(Ty,Var), env)
316+
function var_lt(b::Var, a::Union{Ty,Var}, env)
317317
env.outer = false
318318
bb = env.vars[b]
319319
#println("$b($(bb.lb),$(bb.ub)) <: $a")
@@ -327,7 +327,7 @@ function var_lt(b::Var, a::Union(Ty,Var), env)
327327
return true
328328
end
329329

330-
function var_gt(b::Var, a::Union(Ty,Var), env)
330+
function var_gt(b::Var, a::Union{Ty,Var}, env)
331331
env.outer = false
332332
bb = env.vars[b]
333333
#println("$b($(bb.lb),$(bb.ub)) >: $a")
@@ -451,15 +451,15 @@ function xlate(t::DataType, env)
451451
inst(tn, map(x->xlate(x,env), t.parameters)...)
452452
end
453453

454-
convert(::Type{Ty}, t::Union(Type,Tuple)) = xlate(t)
454+
convert(::Type{Ty}, t::Union{Type,Tuple}) = xlate(t)
455455
convert(::Type{Ty}, t::TypeVar) = xlate(t)
456456

457-
issub(a::Union(Type,Tuple), b::Union(Type,Tuple)) = issub(xlate(a), xlate(b))
458-
issub(a::Ty , b::Union(Type,Tuple)) = issub(a , xlate(b))
459-
issub(a::Union(Type,Tuple), b::Ty ) = issub(xlate(a), b)
460-
issub_env(a::Union(Type,Tuple), b::Union(Type,Tuple)) = issub_env(xlate(a), xlate(b))
461-
issub_env(a::Ty , b::Union(Type,Tuple)) = issub_env(a , xlate(b))
462-
issub_env(a::Union(Type,Tuple), b::Ty ) = issub_env(xlate(a), b)
457+
issub(a::Union{Type,Tuple}, b::Union{Type,Tuple}) = issub(xlate(a), xlate(b))
458+
issub(a::Ty , b::Union{Type,Tuple}) = issub(a , xlate(b))
459+
issub(a::Union{Type,Tuple}, b::Ty ) = issub(xlate(a), b)
460+
issub_env(a::Union{Type,Tuple}, b::Union{Type,Tuple}) = issub_env(xlate(a), xlate(b))
461+
issub_env(a::Ty , b::Union{Type,Tuple}) = issub_env(a , xlate(b))
462+
issub_env(a::Union{Type,Tuple}, b::Ty ) = issub_env(xlate(a), b)
463463

464464
tt(ts...) = Tuple{ts...}
465465
vt(ts...) = Tuple{ts[1:end-1]..., Vararg{ts[end]}}
@@ -687,17 +687,17 @@ end
687687
function test_4()
688688
@test isequal_type(UnionT(BottomT,BottomT), BottomT)
689689

690-
@test issub_strict(Int, Union(Int,String))
691-
@test issub_strict(Union(Int,Int8), Integer)
690+
@test issub_strict(Int, Union{Int,String})
691+
@test issub_strict(Union{Int,Int8}, Integer)
692692

693-
@test isequal_type(Union(Int,Int8), Union(Int,Int8))
693+
@test isequal_type(Union{Int,Int8}, Union{Int,Int8})
694694

695695
@test isequal_type(UnionT(Ty(Int),Ty(Integer)), Ty(Integer))
696696

697-
@test isequal_type(tt(Union(Int,Int8),Int16), Union(tt(Int,Int16),tt(Int8,Int16)))
697+
@test isequal_type(tt(Union{Int,Int8},Int16), Union{tt(Int,Int16),tt(Int8,Int16)})
698698

699-
@test issub_strict((Int,Int8,Int), vt(Union(Int,Int8),))
700-
@test issub_strict((Int,Int8,Int), vt(Union(Int,Int8,Int16),))
699+
@test issub_strict((Int,Int8,Int), vt(Union{Int,Int8},))
700+
@test issub_strict((Int,Int8,Int), vt(Union{Int,Int8,Int16},))
701701

702702
# nested unions
703703
@test !issub(UnionT(Ty(Int),inst(RefT,UnionT(Ty(Int),Ty(Int8)))),
@@ -729,24 +729,24 @@ end
729729

730730
# level 5: union and UnionAll
731731
function test_5()
732-
u = Ty(Union(Int8,Int))
732+
u = Ty(Union{Int8,Int})
733733

734734
@test issub(Ty((String,Array{Int,1})),
735735
(@UnionAll T UnionT(tupletype(T,inst(ArrayT,T,1)),
736736
tupletype(T,inst(ArrayT,Ty(Int),1)))))
737737

738-
@test issub(Ty((Union(Vector{Int},Vector{Int8}),)),
738+
@test issub(Ty((Union{Vector{Int},Vector{Int8}},)),
739739
@UnionAll T tupletype(inst(ArrayT,T,1),))
740740

741-
@test !issub(Ty((Union(Vector{Int},Vector{Int8}),Vector{Int})),
741+
@test !issub(Ty((Union{Vector{Int},Vector{Int8}},Vector{Int})),
742742
@UnionAll T tupletype(inst(ArrayT,T,1), inst(ArrayT,T,1)))
743743

744-
@test !issub(Ty((Union(Vector{Int},Vector{Int8}),Vector{Int8})),
744+
@test !issub(Ty((Union{Vector{Int},Vector{Int8}},Vector{Int8})),
745745
@UnionAll T tupletype(inst(ArrayT,T,1), inst(ArrayT,T,1)))
746746

747747
@test !issub(Ty(Vector{Int}), @UnionAll T>:u inst(ArrayT,T,1))
748748
@test issub(Ty(Vector{Integer}), @UnionAll T>:u inst(ArrayT,T,1))
749-
@test issub(Ty(Vector{Union(Int,Int8)}), @UnionAll T>:u inst(ArrayT,T,1))
749+
@test issub(Ty(Vector{Union{Int,Int8}}), @UnionAll T>:u inst(ArrayT,T,1))
750750

751751
@test issub((@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)),
752752
(@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)))
@@ -832,7 +832,7 @@ function test_6()
832832
@test !issub((@UnionAll i<:T<:i inst(RefT,inst(RefT,T))),
833833
inst(RefT,@UnionAll T<:i inst(RefT,T)))
834834

835-
u = Ty(Union(Int8,Int64))
835+
u = Ty(Union{Int8,Int64})
836836
A = inst(RefT,BottomT)
837837
B = @UnionAll S<:u inst(RefT,S)
838838
@test issub(inst(RefT,B), @UnionAll A<:T<:B inst(RefT,T))
@@ -864,7 +864,7 @@ const menagerie =
864864
Any[BottomT, AnyT, Ty(Int), Ty(Int8), Ty(Integer), Ty(Real),
865865
Ty(Array{Int,1}), Ty(AbstractArray{Int,1}),
866866
Ty(vt(Int,Integer,)), Ty(vt(Integer,Int,)), Ty(()),
867-
Ty(Union(Int,Int8)),
867+
Ty(Union{Int,Int8}),
868868
(@UnionAll T inst(ArrayT, T, 1)),
869869
(@UnionAll T inst(PairT,T,T)),
870870
(@UnionAll T @UnionAll S inst(PairT,T,S)),

test/core.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2989,7 +2989,7 @@ f11715(x) = (x === Tuple{Any})
29892989

29902990
# part of #11597
29912991
# make sure invalid, partly-constructed types don't end up in the cache
2992-
abstract C11597{T<:Union(Void, Int)}
2992+
abstract C11597{T<:Union{Void, Int}}
29932993
type D11597{T} <: C11597{T} d::T end
29942994
@test_throws TypeError D11597(1.0)
29952995
@test_throws TypeError repr(D11597(1.0))

test/docs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ immutable IT
6363
end
6464

6565
"TA"
66-
typealias TA Union(T, IT)
66+
typealias TA Union{T, IT}
6767

6868
"@mac"
6969
macro mac() end

test/unicode/utf32.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ tstcvt(str4_UTF8,str4_UTF16,str4_UTF32)
7575
# Test invalid sequences
7676

7777
strval(::Type{UTF8String}, dat) = dat
78-
strval(::Union(Type{UTF16String},Type{UTF32String}), dat) = UTF8String(dat)
78+
strval(::Union{Type{UTF16String},Type{UTF32String}}, dat) = UTF8String(dat)
7979

8080
byt = 0x0
8181
for T in (UTF8String, UTF16String, UTF32String)

0 commit comments

Comments
 (0)