@@ -102,19 +102,14 @@ for f in (:(!), :(~), :(+), :(-), :(*), :(&), :(|), :(xor),
102
102
:(real), :(imag), :(sign), :(inv))
103
103
@eval ($ f)(:: Missing ) = missing
104
104
end
105
- for f in (:(Base. zero), :(Base. one), :(Base. oneunit))
105
+ for f in (:zero , :one , :oneunit )
106
+ @eval ($ f)(:: Type{Any} ) = throw (MethodError ($ f, (Any,))) # To prevent StackOverflowError
106
107
@eval ($ f)(:: Type{Missing} ) = missing
107
- @eval function $ (f)(:: Type{Union{T, Missing}} ) where T
108
- T === Any && throw (MethodError ($ f, (Any,))) # To prevent StackOverflowError
109
- $ f (T)
110
- end
108
+ @eval ($ f)(:: Type{T} ) where {T>: Missing } = $ f (nonmissingtype_checked (T))
111
109
end
112
- for f in (:(Base. float), :(Base. complex))
113
- @eval $ f (:: Type{Missing} ) = Missing
114
- @eval function $f (:: Type{Union{T, Missing}} ) where T
115
- T === Any && throw (MethodError ($ f, (Any,))) # To prevent StackOverflowError
116
- Union{$ f (T), Missing}
117
- end
110
+ for f in (:float , :real , :complex )
111
+ @eval ($ f)(:: Type{Any} ) = throw (MethodError ($ f, (Any,))) # To prevent StackOverflowError
112
+ @eval ($ f)(:: Type{T} ) where {T>: Missing } = Union{$ f (nonmissingtype (T)), Missing}
118
113
end
119
114
120
115
# Binary operators/functions
0 commit comments