@@ -191,16 +191,9 @@ for FUNC in (:conversion_rule,:maxspace_rule,:union_rule)
191
191
@eval $ FUNC (a, b) = _conversion_rule (a, b)
192
192
end
193
193
194
-
195
-
196
- for FUNC in (:conversion_type ,:maxspace )
197
- @eval begin
198
- $ FUNC (a:: UnsetSpace ,b:: UnsetSpace ) = a
199
- $ FUNC (a:: UnsetSpace ,b:: Space ) = b
200
- $ FUNC (a:: Space ,b:: UnsetSpace ) = a
201
- end
202
- end
203
-
194
+ pick_maybe_nonambiguous_space (a:: Space , b... ) = a
195
+ pick_maybe_nonambiguous_space (a:: AmbiguousSpace , b) = pick_maybe_nonambiguous_space (b)
196
+ pick_maybe_nonambiguous_space (a:: NoSpace , b... ) = a
204
197
205
198
"""
206
199
conversion_type(a::Space, b::Space)
@@ -210,7 +203,10 @@ Override `ApproxFun.conversion_rule` when adding new `Conversion` operators.
210
203
211
204
See also [`maxspace`](@ref)
212
205
"""
213
- function conversion_type (a,b)
206
+ function conversion_type (a, b)
207
+ if a isa UnsetSpace || b isa UnsetSpace
208
+ return pick_maybe_nonambiguous_space (a, b)
209
+ end
214
210
if spacescompatible (a,b)
215
211
a
216
212
elseif ! domainscompatible (a,b)
@@ -235,6 +231,10 @@ See also [`conversion_type`](@ref)
235
231
"""
236
232
maxspace (a,b) = NoSpace () # TODO : this fixes weird bug with Nothing
237
233
function maxspace (a:: Space , b:: Space )
234
+ if a isa UnsetSpace || b isa UnsetSpace
235
+ return pick_maybe_nonambiguous_space (a, b)
236
+ end
237
+
238
238
if spacescompatible (a,b)
239
239
return a
240
240
elseif ! domainscompatible (a,b)
@@ -290,11 +290,11 @@ end
290
290
# this is used primarily for addition of two funs
291
291
# that may be incompatible
292
292
union (a:: AmbiguousSpace , b:: AmbiguousSpace ) = b
293
- union_by_union_rule (a:: AmbiguousSpace , b:: Space ) = b
294
- union_by_union_rule (a:: Space , b:: AmbiguousSpace ) = a
295
-
296
293
297
294
function union_by_union_rule (@nospecialize (a:: Space ), @nospecialize (b:: Space ))
295
+ if a isa AmbiguousSpace || b isa AmbiguousSpace
296
+ return pick_maybe_nonambiguous_space (a, b)
297
+ end
298
298
if spacescompatible (a,b)
299
299
if isambiguous (domain (a))
300
300
return b
@@ -319,7 +319,7 @@ function union(@nospecialize(a::Space), @nospecialize(b::Space))
319
319
crc = union_by_union_rule (cspa,cspb)
320
320
crc isa NoSpace || return crc
321
321
end
322
- # TODO : Uncomment when Julia bug is fixed
322
+
323
323
cr2= maxspace (a,b) # Max space since we can convert both to it
324
324
cr2 isa NoSpace || return cr2
325
325
@@ -591,12 +591,9 @@ domain(S::ZeroSpace) = S.domain
591
591
dimension (:: ZeroSpace ) = 0
592
592
593
593
spacescompatible (:: ZeroSpace ,:: ZeroSpace ) = true
594
- for FUNC in (:conversion_type ,:maxspace )
595
- @eval begin
596
- $ FUNC (:: ZeroSpace ,:: UnsetSpace ) = UnsetSpace ()
597
- $ FUNC (:: UnsetSpace ,:: ZeroSpace ) = UnsetSpace ()
598
- end
599
- end
594
+
595
+ pick_maybe_nonambiguous_space (a:: UnsetSpace , b:: ZeroSpace ) = a
596
+ pick_maybe_nonambiguous_space (a:: ZeroSpace , b:: UnsetSpace ) = b
600
597
601
598
602
599
"""
0 commit comments