From 903c4641a544f67427feffffd4d32fc14064028b Mon Sep 17 00:00:00 2001 From: Amit Murthy Date: Tue, 18 Oct 2016 13:16:52 +0530 Subject: [PATCH] deprecated Channel() instead of throwing an error --- base/channels.jl | 11 +++++++++++ base/deprecated.jl | 3 +++ test/channels.jl | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/base/channels.jl b/base/channels.jl index 409e950297211..2648df4403eb5 100644 --- a/base/channels.jl +++ b/base/channels.jl @@ -26,10 +26,21 @@ type Channel{T} <: AbstractChannel end new(Condition(), Condition(), :open, Array{T}(0), sz, Array{Condition}(0)) end + + # deprecated empty constructor + function Channel() + depwarn(string("The empty constructor Channel() is deprecated. ", + "The channel size needs to be specified explictly. ", + "Defaulting to Channel{$T}(32)."), :Channel) + Channel(32) + end end Channel(sz) = Channel{Any}(sz) +# deprecated empty constructor +Channel() = Channel{Any}() + closed_exception() = InvalidStateException("Channel is closed.", :closed) isbuffered(c::Channel) = c.sz_max==0 ? false : true diff --git a/base/deprecated.jl b/base/deprecated.jl index ccc15d183442f..43d0e7a202d47 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1023,4 +1023,7 @@ end)) @deprecate is (===) +# NOTE: Deprecation of Channel{T}() is implemented in channels.jl. +# To be removed from there when 0.6 deprecations are removed. + # End deprecations scheduled for 0.6 diff --git a/test/channels.jl b/test/channels.jl index a3699fcf4f9d6..620b433b2795c 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -20,7 +20,9 @@ pvals = map(i->put!(c,i), 1:10^6) tvals = Int[take!(c) for i in 1:10^6] @test pvals == tvals -@test_throws MethodError Channel() +# Uncomment line below once deprecation support has been removed. +# @test_throws MethodError Channel() + @test_throws ArgumentError Channel(-1) @test_throws InexactError Channel(1.5)