Skip to content

Commit 83a209d

Browse files
avoid special case for Windows
1 parent e96d9ec commit 83a209d

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/variable.jl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,27 @@ Default fill-value for the given type from NetCDF.
6565
@inline fillvalue(::Type{String}) = ""
6666

6767

68+
# based on:
69+
# https://github.com/JuliaLang/julia/blob/94fd312df03d5075796fbd2e8b47288a84a1c6de/base/promotion.jl#L141
70+
# MIT
71+
# typesplit(Union{Float64,Missing},Missing) == Float64
72+
function typesplit(@nospecialize(TS), @nospecialize(T))
73+
if TS <: T
74+
return Union{}
75+
end
76+
if isa(TS, Union)
77+
return Union{typesplit(TS.a, T),
78+
typesplit(TS.b, T)}
79+
end
80+
return TS
81+
end
6882

6983
# convert e.g. Union{Float64,Missing} to Float64
7084
# similar to Base.nonmissingtype
71-
_nonuniontype(::Type{T},::Type{Union{T,S}}) where {T,S} = S
85+
7286
function nonuniontype(T,TS)
7387
if typeof(TS) == Union
74-
# https://github.com/JuliaLang/julia/issues/53136
75-
@static if (VERSION < v"1.8") && Sys.iswindows()
76-
if TS.a == T
77-
return TS.b
78-
elseif TS.b == T
79-
return TS.a
80-
else
81-
return TS
82-
end
83-
else
84-
_nonuniontype(T,TS)
85-
end
88+
return typesplit(TS, T)
8689
else
8790
TS
8891
end

0 commit comments

Comments
 (0)