Skip to content

Commit 903c464

Browse files
committed
deprecated Channel() instead of throwing an error
1 parent 2e854b4 commit 903c464

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

base/channels.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,21 @@ type Channel{T} <: AbstractChannel
2626
end
2727
new(Condition(), Condition(), :open, Array{T}(0), sz, Array{Condition}(0))
2828
end
29+
30+
# deprecated empty constructor
31+
function Channel()
32+
depwarn(string("The empty constructor Channel() is deprecated. ",
33+
"The channel size needs to be specified explictly. ",
34+
"Defaulting to Channel{$T}(32)."), :Channel)
35+
Channel(32)
36+
end
2937
end
3038

3139
Channel(sz) = Channel{Any}(sz)
3240

41+
# deprecated empty constructor
42+
Channel() = Channel{Any}()
43+
3344
closed_exception() = InvalidStateException("Channel is closed.", :closed)
3445

3546
isbuffered(c::Channel) = c.sz_max==0 ? false : true

base/deprecated.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,4 +1023,7 @@ end))
10231023

10241024
@deprecate is (===)
10251025

1026+
# NOTE: Deprecation of Channel{T}() is implemented in channels.jl.
1027+
# To be removed from there when 0.6 deprecations are removed.
1028+
10261029
# End deprecations scheduled for 0.6

test/channels.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ pvals = map(i->put!(c,i), 1:10^6)
2020
tvals = Int[take!(c) for i in 1:10^6]
2121
@test pvals == tvals
2222

23-
@test_throws MethodError Channel()
23+
# Uncomment line below once deprecation support has been removed.
24+
# @test_throws MethodError Channel()
25+
2426
@test_throws ArgumentError Channel(-1)
2527
@test_throws InexactError Channel(1.5)
2628

0 commit comments

Comments
 (0)