Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/scalar/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
2 changes: 2 additions & 0 deletions test/scalar/test_basederived.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down