Skip to content

Commit f93afea

Browse files
committed
Drop compat code for Some from #435 and #563
But only mark `notnothing` for deprecation.
1 parent d744d24 commit f93afea

File tree

4 files changed

+12
-51
lines changed

4 files changed

+12
-51
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes:
8383
* `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized
8484
as the second ([#24605]).
8585

86-
* `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]).
87-
8886
* `replace` accepts a pair of pattern and replacement, with the number of replacements as
8987
a keyword argument ([#25165]).
9088

src/Compat.jl

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module Unicode
4242
using Unicode
4343
import Unicode: isassigned, normalize # not exported from Unicode module due to conflicts
4444
end
45+
import Base: notnothing
4546

4647

4748
include("compatmacro.jl")
@@ -67,40 +68,6 @@ end
6768
end
6869
end
6970

70-
71-
72-
@static if !isdefined(Base, :Some)
73-
import Base: promote_rule, convert
74-
struct Some{T}
75-
value::T
76-
end
77-
promote_rule(::Type{Some{T}}, ::Type{Some{S}}) where {T,S<:T} = Some{T}
78-
promote_rule(::Type{Some{T}}, ::Type{Nothing}) where {T} = Union{Some{T}, Nothing}
79-
convert(::Type{Some{T}}, x::Some) where {T} = Some{T}(convert(T, x.value))
80-
convert(::Type{Union{Some{T}, Nothing}}, x::Some) where {T} = convert(Some{T}, x)
81-
82-
convert(::Type{Union{T, Nothing}}, x::Any) where {T} = convert(T, x)
83-
convert(::Type{Nothing}, x::Any) = throw(MethodError(convert, (Nothing, x)))
84-
convert(::Type{Nothing}, x::Nothing) = nothing
85-
86-
# Note: this is the definition of coalasce prior to 0.7.0-DEV.5278; kept to avoid
87-
# breakage in packages already using it
88-
coalesce(x::Any) = x
89-
coalesce(x::Some) = x.value
90-
coalesce(x::Nothing) = nothing
91-
#coalesce(x::Missing) = missing
92-
coalesce(x::Any, y...) = x
93-
coalesce(x::Some, y...) = x.value
94-
coalesce(x::Nothing, y...) = coalesce(y...)
95-
#coalesce(x::Union{Nothing, Missing}, y...) = coalesce(y...)
96-
97-
notnothing(x::Any) = x
98-
notnothing(::Nothing) = throw(ArgumentError("nothing passed to notnothing"))
99-
export Some, coalesce
100-
else
101-
import Base: notnothing
102-
end
103-
10471
# 0.7.0-DEV.3309
10572
@static if VERSION < v"0.7.0-DEV.3309"
10673
const IteratorSize = Base.iteratorsize

test/old.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ module Test25021
183183
@test Compat.Unicode.normalize("\t\r", stripcc=true) == " "
184184
end
185185

186+
# 0.7.0-DEV.3017
187+
@test Compat.notnothing(1) == 1
188+
@test_throws ArgumentError Compat.notnothing(nothing)
189+
186190

187191
# tests of removed functionality (i.e. justs tests Base)
188192

@@ -581,3 +585,10 @@ end
581585
# 0.7.0-DEV.3137
582586
@test Nothing === (isdefined(Base, :Nothing) ? Base.Nothing : Base.Void)
583587
@test Nothing === Cvoid
588+
589+
# 0.7.0-DEV.3017
590+
@test isa(Some(1), Some{Int})
591+
@test convert(Some{Float64}, Some(1)) == Some(1.0)
592+
@test convert(Nothing, nothing) == nothing
593+
@test_throws MethodError convert(Nothing, 1)
594+
@test Some(nothing) != nothing

test/runtests.jl

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,6 @@ let A = [1]
8080
@test x == 1
8181
end
8282

83-
# 0.7.0-DEV.3017
84-
@test isa(Some(1), Some{Int})
85-
@test convert(Some{Float64}, Some(1)) == Some(1.0)
86-
@test convert(Nothing, nothing) == nothing
87-
@test_throws MethodError convert(Nothing, 1)
88-
@test Some(nothing) != nothing
89-
if VERSION < v"0.7.0-DEV.5278"
90-
# coalesce has changed; old behavior kept and tested to avoid accidental breakage
91-
@test coalesce(Some(1)) == 1
92-
@test coalesce(nothing) == nothing
93-
@test coalesce(nothing, Some(1), Some(2)) == 1
94-
end
95-
@test Compat.notnothing(1) == 1
96-
@test_throws ArgumentError Compat.notnothing(nothing)
97-
9883
# 0.7.0-DEV.3309
9984
let v = [1, 2, 3]
10085
@test Compat.IteratorSize(v) isa Base.HasShape

0 commit comments

Comments
 (0)