File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -65,24 +65,27 @@ Default fill-value for the given type from NetCDF.
65
65
@inline fillvalue (:: Type{String} ) = " "
66
66
67
67
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
68
82
69
83
# convert e.g. Union{Float64,Missing} to Float64
70
84
# similar to Base.nonmissingtype
71
- _nonuniontype ( :: Type{T} , :: Type{Union{T,S}} ) where {T,S} = S
85
+
72
86
function nonuniontype (T,TS)
73
87
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)
86
89
else
87
90
TS
88
91
end
You can’t perform that action at this time.
0 commit comments