Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nonmissingtype with unspecified type parameters #31016

Merged
merged 2 commits into from
Apr 2, 2019
Merged
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
6 changes: 1 addition & 5 deletions base/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ end
showerror(io::IO, ex::MissingException) =
print(io, "MissingException: ", ex.msg)


nonmissingtype(::Type{Union{T, Missing}}) where {T} = T
nonmissingtype(::Type{Missing}) = Union{}
nonmissingtype(::Type{T}) where {T} = T
nonmissingtype(::Type{Any}) = Any
nonmissingtype(::Type{T}) where {T} = Core.Compiler.typesubtract(T, Missing)

for U in (:Nothing, :Missing)
@eval begin
Expand Down
1 change: 0 additions & 1 deletion test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ end
pop!(need_to_handle_undef_sparam, which(Base.zero, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.one, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.oneunit, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.nonmissingtype, Tuple{Type{Union{Missing, T}} where T}))
pop!(need_to_handle_undef_sparam, which(Base.convert, (Type{Union{Some{T}, Nothing}} where T, Some)))
pop!(need_to_handle_undef_sparam, which(Base.convert, (Type{Union{T, Nothing}} where T, Some)))
pop!(need_to_handle_undef_sparam, which(Base.convert, Tuple{Type{Tuple{Vararg{Int}}}, Tuple{}}))
Expand Down
1 change: 1 addition & 0 deletions test/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ end

@testset "nonmissingtype" begin
@test Base.nonmissingtype(Union{Int, Missing}) == Int
@test Base.nonmissingtype(Union{Rational, Missing}) == Rational
@test Base.nonmissingtype(Any) == Any
@test Base.nonmissingtype(Missing) == Union{}
end
Expand Down