diff --git a/src/scalar/core.jl b/src/scalar/core.jl index 2c1875d..d54df39 100644 --- a/src/scalar/core.jl +++ b/src/scalar/core.jl @@ -39,7 +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 -Base.convert(::Type{Any}, ::DataValue{Union{}}) = NA +@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)} diff --git a/test/scalar/test_basederived.jl b/test/scalar/test_basederived.jl index 1190891..506967e 100644 --- a/test/scalar/test_basederived.jl +++ b/test/scalar/test_basederived.jl @@ -374,6 +374,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}