From 1a3da0a955f320895db1c32355fd0437c3c2a365 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Sat, 22 Dec 2018 11:23:46 -0800 Subject: [PATCH 1/2] Remove a convert method --- src/scalar/core.jl | 1 - test/scalar/test_basederived.jl | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scalar/core.jl b/src/scalar/core.jl index 1e34946..f2271a4 100644 --- a/src/scalar/core.jl +++ b/src/scalar/core.jl @@ -36,7 +36,6 @@ Base.convert(::Type{DataValue}, ::Nothing) = DataValue{Union{}}() Base.convert(::Type{Union{Missing, T}}, value::DataValues.DataValue{T}) where T = isna(value) ? missing : value[] Base.convert(::Type{Union{Missing, T}}, ::DataValues.DataValue{Union{}}) where T = missing -Base.convert(::Type{Any}, ::DataValue{Union{}}) = NA Base.convert(::Type{Missing}, ::DataValue{Union{}}) = missing Base.promote_rule(::Type{DataValue{S}}, ::Type{T}) where {S,T} = DataValue{promote_type(S, T)} diff --git a/test/scalar/test_basederived.jl b/test/scalar/test_basederived.jl index bcaba46..990ceb4 100644 --- a/test/scalar/test_basederived.jl +++ b/test/scalar/test_basederived.jl @@ -371,6 +371,8 @@ end @test isequal(convert(DataValue, "a"), DataValue("a")) @test isequal(convert(DataValue, DataValue("a")), DataValue("a")) +@test convert(Any, NA) == NA + @test promote_type(DataValue{Int}, Int) === DataValue{Int} @test promote_type(DataValue{Union{}}, Int) === DataValue{Int} @test promote_type(DataValue{Float64}, DataValue{Int}) === DataValue{Float64} From 6c55dfb378f41354206d0164478c3b8b683756b9 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Sun, 4 Aug 2019 11:29:53 -0700 Subject: [PATCH 2/2] Add VERSION check to a convert method --- src/scalar/core.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/scalar/core.jl b/src/scalar/core.jl index 0a7f023..d54df39 100644 --- a/src/scalar/core.jl +++ b/src/scalar/core.jl @@ -39,6 +39,9 @@ Base.convert(::Type{DataValue}, ::Nothing) = DataValue{Union{}}() Base.convert(::Type{Union{Missing, T}}, value::DataValues.DataValue{T}) where T = get(value, missing) Base.convert(::Type{Union{Missing, T}}, ::DataValues.DataValue{Union{}}) where T = missing +@static if VERSION < v"1.1" + Base.convert(::Type{Any}, ::DataValue{Union{}}) = NA +end Base.convert(::Type{Missing}, ::DataValue{Union{}}) = missing Base.promote_rule(::Type{DataValue{S}}, ::Type{T}) where {S,T} = DataValue{promote_type(S, T)}