Skip to content

Commit

Permalink
convert more Union(...) to Union{...} instances that escaped JuliaLan…
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Aug 13, 2015
1 parent bb4eddc commit 4b0fd13
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ type SharedMemSpec
create :: Bool
end
export mmap_array
function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union(IO,SharedMemSpec), offset::FileOffset)
function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::Union{IO,SharedMemSpec}, offset::FileOffset)
depwarn("`mmap_array` is deprecated, use `Mmap.mmap(io, Array{T,N}, dims, offset)` instead to return an mmapped-array", :mmap_array)
if isa(s,SharedMemSpec)
a = Mmap.Anonymous(s.name, s.readonly, s.create)
Expand Down
10 changes: 5 additions & 5 deletions base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ for f in (:fft, :bfft, :ifft)
@eval begin
$f{T<:Real}(x::AbstractArray{T}, region=1:ndims(x)) = $f(complexfloat(x), region)
$pf{T<:Real}(x::AbstractArray{T}, region; kws...) = $pf(complexfloat(x), region; kws...)
$f{T<:Union(Integer,Rational)}(x::AbstractArray{Complex{T}}, region=1:ndims(x)) = $f(complexfloat(x), region)
$pf{T<:Union(Integer,Rational)}(x::AbstractArray{Complex{T}}, region; kws...) = $pf(complexfloat(x), region; kws...)
$f{T<:Union{Integer,Rational}}(x::AbstractArray{Complex{T}}, region=1:ndims(x)) = $f(complexfloat(x), region)
$pf{T<:Union{Integer,Rational}}(x::AbstractArray{Complex{T}}, region; kws...) = $pf(complexfloat(x), region; kws...)
end
end
rfft{T<:Union(Integer,Rational)}(x::AbstractArray{T}, region=1:ndims(x)) = rfft(float(x), region)
plan_rfft{T<:Union(Integer,Rational)}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...)
rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region=1:ndims(x)) = rfft(float(x), region)
plan_rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...)

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

Expand Down
2 changes: 1 addition & 1 deletion base/docs/helpdb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2614,7 +2614,7 @@ rol
doc"""
```rst
::
Mmap.mmap(io::Union(IOStream,AbstractString,Mmap.AnonymousMmap)[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
Mmap.mmap(io::Union{IOStream,AbstractString,Mmap.AnonymousMmap}[, type::Type{Array{T,N}}, dims, offset]; grow::Bool=true, shared::Bool=true)
Mmap.mmap(type::Type{Array{T,N}}, dims)
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.
Expand Down
14 changes: 7 additions & 7 deletions base/fft/FFTW.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ end

# FFTW floating-point types:

typealias fftwNumber Union(Float64,Float32,Complex128,Complex64)
typealias fftwReal Union(Float64,Float32)
typealias fftwComplex Union(Complex128,Complex64)
typealias fftwDouble Union(Float64,Complex128)
typealias fftwSingle Union(Float32,Complex64)
typealias fftwTypeDouble Union(Type{Float64},Type{Complex128})
typealias fftwTypeSingle Union(Type{Float32},Type{Complex64})
typealias fftwNumber Union{Float64,Float32,Complex128,Complex64}
typealias fftwReal Union{Float64,Float32}
typealias fftwComplex Union{Complex128,Complex64}
typealias fftwDouble Union{Float64,Complex128}
typealias fftwSingle Union{Float32,Complex64}
typealias fftwTypeDouble Union{Type{Float64},Type{Complex128}}
typealias fftwTypeSingle Union{Type{Float32},Type{Complex64}}

# For ESTIMATE plans, FFTW allows one to pass NULL for the array pointer,
# since it is not written to. Hence, it is convenient to create an
Expand Down
2 changes: 1 addition & 1 deletion base/floatfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ const ≈ = isapprox
# default tolerance arguments
rtoldefault{T<:AbstractFloat}(::Type{T}) = sqrt(eps(T))
rtoldefault{T<:Real}(::Type{T}) = 0
rtoldefault{T<:Number,S<:Number}(x::Union(T,Type{T}), y::Union(S,Type{S})) = rtoldefault(promote_type(real(T),real(S)))
rtoldefault{T<:Number,S<:Number}(x::Union{T,Type{T}}, y::Union{S,Type{S}}) = rtoldefault(promote_type(real(T),real(S)))
4 changes: 2 additions & 2 deletions base/poll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ function close(t::FDWatcher)
close(t.watcher, r, w)
end

function uvfinalize(uv::Union(FileMonitor, PollingFileWatcher))
function uvfinalize(uv::Union{FileMonitor, PollingFileWatcher})
disassociate_julia_struct(uv)
close(uv)
end

function close(t::Union(FileMonitor, PollingFileWatcher))
function close(t::Union{FileMonitor, PollingFileWatcher})
if t.handle != C_NULL
ccall(:jl_close_uv, Void, (Ptr{Void},), t.handle)
t.handle = C_NULL
Expand Down
6 changes: 3 additions & 3 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ immutable InsertionSortAlg <: Algorithm end
immutable QuickSortAlg <: Algorithm end
immutable MergeSortAlg <: Algorithm end

immutable PartialQuickSort{T <: Union(Int,OrdinalRange)} <: Algorithm
immutable PartialQuickSort{T <: Union{Int,OrdinalRange}} <: Algorithm
k::T
end

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

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

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

function selectperm!{I<:Integer}(ix::AbstractVector{I}, v::AbstractVector,
k::Union(Int, OrdinalRange);
k::Union{Int, OrdinalRange};
lt::Function=isless,
by::Function=identity,
rev::Bool=false,
Expand Down
4 changes: 2 additions & 2 deletions doc/manual/integers-and-floating-point-numbers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,15 @@ imply multiplication:
julia> (x-1)(x+1)
ERROR: MethodError: `call` has no method matching call(::Int64, ::Int64)
Closest candidates are:
Union(!Matched::Any...)
Union{!Matched::Any...}
BoundsError()
BoundsError(!Matched::Any...)
...

julia> x(x+1)
ERROR: MethodError: `call` has no method matching call(::Int64, ::Int64)
Closest candidates are:
Union(!Matched::Any...)
Union{!Matched::Any...}
BoundsError()
BoundsError(!Matched::Any...)
...
Expand Down
4 changes: 2 additions & 2 deletions doc/stdlib/io-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ Memory-mapped I/O

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.

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

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

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

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.
Expand Down
46 changes: 23 additions & 23 deletions examples/juliatypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type UnionAllT <: Ty
var::Var
T
UnionAllT(v::Var, t) = new(v, t)
UnionAllT(v::Var, t::Union(Type,Tuple)) = new(v, convert(Ty, t))
UnionAllT(v::Var, t::Union{Type,Tuple}) = new(v, convert(Ty, t))
end

function show(io::IO, x::UnionAllT)
Expand Down Expand Up @@ -313,7 +313,7 @@ function issub(a::Var, b::Var, env)
end
end

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

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

convert(::Type{Ty}, t::Union(Type,Tuple)) = xlate(t)
convert(::Type{Ty}, t::Union{Type,Tuple}) = xlate(t)
convert(::Type{Ty}, t::TypeVar) = xlate(t)

issub(a::Union(Type,Tuple), b::Union(Type,Tuple)) = issub(xlate(a), xlate(b))
issub(a::Ty , b::Union(Type,Tuple)) = issub(a , xlate(b))
issub(a::Union(Type,Tuple), b::Ty ) = issub(xlate(a), b)
issub_env(a::Union(Type,Tuple), b::Union(Type,Tuple)) = issub_env(xlate(a), xlate(b))
issub_env(a::Ty , b::Union(Type,Tuple)) = issub_env(a , xlate(b))
issub_env(a::Union(Type,Tuple), b::Ty ) = issub_env(xlate(a), b)
issub(a::Union{Type,Tuple}, b::Union{Type,Tuple}) = issub(xlate(a), xlate(b))
issub(a::Ty , b::Union{Type,Tuple}) = issub(a , xlate(b))
issub(a::Union{Type,Tuple}, b::Ty ) = issub(xlate(a), b)
issub_env(a::Union{Type,Tuple}, b::Union{Type,Tuple}) = issub_env(xlate(a), xlate(b))
issub_env(a::Ty , b::Union{Type,Tuple}) = issub_env(a , xlate(b))
issub_env(a::Union{Type,Tuple}, b::Ty ) = issub_env(xlate(a), b)

tt(ts...) = Tuple{ts...}
vt(ts...) = Tuple{ts[1:end-1]..., Vararg{ts[end]}}
Expand Down Expand Up @@ -687,17 +687,17 @@ end
function test_4()
@test isequal_type(UnionT(BottomT,BottomT), BottomT)

@test issub_strict(Int, Union(Int,String))
@test issub_strict(Union(Int,Int8), Integer)
@test issub_strict(Int, Union{Int,String})
@test issub_strict(Union{Int,Int8}, Integer)

@test isequal_type(Union(Int,Int8), Union(Int,Int8))
@test isequal_type(Union{Int,Int8}, Union{Int,Int8})

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

@test isequal_type(tt(Union(Int,Int8),Int16), Union(tt(Int,Int16),tt(Int8,Int16)))
@test isequal_type(tt(Union{Int,Int8},Int16), Union{tt(Int,Int16),tt(Int8,Int16)})

@test issub_strict((Int,Int8,Int), vt(Union(Int,Int8),))
@test issub_strict((Int,Int8,Int), vt(Union(Int,Int8,Int16),))
@test issub_strict((Int,Int8,Int), vt(Union{Int,Int8},))
@test issub_strict((Int,Int8,Int), vt(Union{Int,Int8,Int16},))

# nested unions
@test !issub(UnionT(Ty(Int),inst(RefT,UnionT(Ty(Int),Ty(Int8)))),
Expand Down Expand Up @@ -729,24 +729,24 @@ end

# level 5: union and UnionAll
function test_5()
u = Ty(Union(Int8,Int))
u = Ty(Union{Int8,Int})

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

@test issub(Ty((Union(Vector{Int},Vector{Int8}),)),
@test issub(Ty((Union{Vector{Int},Vector{Int8}},)),
@UnionAll T tupletype(inst(ArrayT,T,1),))

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

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

@test !issub(Ty(Vector{Int}), @UnionAll T>:u inst(ArrayT,T,1))
@test issub(Ty(Vector{Integer}), @UnionAll T>:u inst(ArrayT,T,1))
@test issub(Ty(Vector{Union(Int,Int8)}), @UnionAll T>:u inst(ArrayT,T,1))
@test issub(Ty(Vector{Union{Int,Int8}}), @UnionAll T>:u inst(ArrayT,T,1))

@test issub((@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)),
(@UnionAll Ty(Int)<:T<:u inst(ArrayT,T,1)))
Expand Down Expand Up @@ -832,7 +832,7 @@ function test_6()
@test !issub((@UnionAll i<:T<:i inst(RefT,inst(RefT,T))),
inst(RefT,@UnionAll T<:i inst(RefT,T)))

u = Ty(Union(Int8,Int64))
u = Ty(Union{Int8,Int64})
A = inst(RefT,BottomT)
B = @UnionAll S<:u inst(RefT,S)
@test issub(inst(RefT,B), @UnionAll A<:T<:B inst(RefT,T))
Expand Down Expand Up @@ -864,7 +864,7 @@ const menagerie =
Any[BottomT, AnyT, Ty(Int), Ty(Int8), Ty(Integer), Ty(Real),
Ty(Array{Int,1}), Ty(AbstractArray{Int,1}),
Ty(vt(Int,Integer,)), Ty(vt(Integer,Int,)), Ty(()),
Ty(Union(Int,Int8)),
Ty(Union{Int,Int8}),
(@UnionAll T inst(ArrayT, T, 1)),
(@UnionAll T inst(PairT,T,T)),
(@UnionAll T @UnionAll S inst(PairT,T,S)),
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,7 @@ f11715(x) = (x === Tuple{Any})

# part of #11597
# make sure invalid, partly-constructed types don't end up in the cache
abstract C11597{T<:Union(Void, Int)}
abstract C11597{T<:Union{Void, Int}}
type D11597{T} <: C11597{T} d::T end
@test_throws TypeError D11597(1.0)
@test_throws TypeError repr(D11597(1.0))
Expand Down
2 changes: 1 addition & 1 deletion test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ immutable IT
end

"TA"
typealias TA Union(T, IT)
typealias TA Union{T, IT}

"@mac"
macro mac() end
Expand Down
2 changes: 1 addition & 1 deletion test/unicode/utf32.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ tstcvt(str4_UTF8,str4_UTF16,str4_UTF32)
# Test invalid sequences

strval(::Type{UTF8String}, dat) = dat
strval(::Union(Type{UTF16String},Type{UTF32String}), dat) = UTF8String(dat)
strval(::Union{Type{UTF16String},Type{UTF32String}}, dat) = UTF8String(dat)

byt = 0x0
for T in (UTF8String, UTF16String, UTF32String)
Expand Down

0 comments on commit 4b0fd13

Please sign in to comment.