diff --git a/base/deprecated.jl b/base/deprecated.jl index 8d5b220ef0f82..73da5433951d2 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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) diff --git a/base/dft.jl b/base/dft.jl index 0288fa6798ae6..706d55c259389 100644 --- a/base/dft.jl +++ b/base/dft.jl @@ -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) @@ -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 diff --git a/base/docs/helpdb.jl b/base/docs/helpdb.jl index 340a6e4370c0b..f77c1b2eee3d3 100644 --- a/base/docs/helpdb.jl +++ b/base/docs/helpdb.jl @@ -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. diff --git a/base/fft/FFTW.jl b/base/fft/FFTW.jl index dce63807cbf37..694c9eafff451 100644 --- a/base/fft/FFTW.jl +++ b/base/fft/FFTW.jl @@ -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 diff --git a/base/floatfuncs.jl b/base/floatfuncs.jl index 1cfa63c6e95f9..f3442335f604b 100644 --- a/base/floatfuncs.jl +++ b/base/floatfuncs.jl @@ -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))) diff --git a/base/poll.jl b/base/poll.jl index c7bf9f14d3d18..fb334d7cdc85f 100644 --- a/base/poll.jl +++ b/base/poll.jl @@ -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 diff --git a/base/sort.jl b/base/sort.jl index 87938fda9f360..792d2db587cec 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -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 @@ -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, diff --git a/doc/stdlib/io-network.rst b/doc/stdlib/io-network.rst index b84b072e81155..dc660e7ef9a07 100644 --- a/doc/stdlib/io-network.rst +++ b/doc/stdlib/io-network.rst @@ -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) @@ -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. diff --git a/examples/juliatypes.jl b/examples/juliatypes.jl index 2b49a75f8596e..1b19dae1c6816 100644 --- a/examples/juliatypes.jl +++ b/examples/juliatypes.jl @@ -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) @@ -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") @@ -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") @@ -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]}} @@ -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)))), @@ -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))) @@ -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)) @@ -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)), diff --git a/test/core.jl b/test/core.jl index c68e0e2431265..94e4ad40f08c2 100644 --- a/test/core.jl +++ b/test/core.jl @@ -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)) diff --git a/test/docs.jl b/test/docs.jl index ea65bcc07768b..c0c48a8dad072 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -63,7 +63,7 @@ immutable IT end "TA" -typealias TA Union(T, IT) +typealias TA Union{T, IT} "@mac" macro mac() end diff --git a/test/unicode/utf32.jl b/test/unicode/utf32.jl index 5a348dc78da71..c83ed7eececf9 100644 --- a/test/unicode/utf32.jl +++ b/test/unicode/utf32.jl @@ -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)