@@ -75,7 +75,7 @@ function instanceof_tfunc(@nospecialize(t))
7575 t = widenconst (t)
7676 if t === Bottom
7777 return Bottom, true , true , false # runtime unreachable
78- elseif t === typeof (Bottom) || typeintersect (t, Type) === Bottom
78+ elseif t === typeof (Bottom) || ! hasintersect (t, Type)
7979 return Bottom, true , false , false # literal Bottom or non-Type
8080 elseif isType (t)
8181 tp = t. parameters[1 ]
@@ -246,7 +246,7 @@ function egal_tfunc(@nospecialize(x), @nospecialize(y))
246246 return Const (false )
247247 elseif isa (xx, Const) && isa (yy, Const)
248248 return Const (xx. val === yy. val)
249- elseif typeintersect (widenconst (xx), widenconst (yy)) === Bottom
249+ elseif ! hasintersect (widenconst (xx), widenconst (yy))
250250 return Const (false )
251251 elseif (isa (xx, Const) && y === typeof (xx. val) && isdefined (y, :instance )) ||
252252 (isa (yy, Const) && x === typeof (yy. val) && isdefined (x, :instance ))
@@ -258,9 +258,9 @@ add_tfunc(===, 2, 2, egal_tfunc, 1)
258258
259259function isdefined_nothrow (argtypes:: Array{Any, 1} )
260260 length (argtypes) == 2 || return false
261- return typeintersect (widenconst (argtypes[1 ]), Module) === Union{} ?
262- (argtypes[ 2 ] ⊑ Symbol || argtypes[2 ] ⊑ Int) :
263- argtypes[2 ] ⊑ Symbol
261+ return hasintersect (widenconst (argtypes[1 ]), Module) ?
262+ argtypes[2 ] ⊑ Symbol :
263+ ( argtypes[2 ] ⊑ Symbol || argtypes[ 2 ] ⊑ Int)
264264end
265265isdefined_tfunc (arg1, sym, order) = (@nospecialize ; isdefined_tfunc (arg1, sym))
266266function isdefined_tfunc (@nospecialize (arg1), @nospecialize (sym))
@@ -275,8 +275,9 @@ function isdefined_tfunc(@nospecialize(arg1), @nospecialize(sym))
275275 a1 = unwrap_unionall (a1)
276276 if isa (a1, DataType) && ! isabstracttype (a1)
277277 if a1 === Module
278- Symbol <: widenconst (sym) || return Bottom
279- if isa (sym, Const) && isa (sym. val, Symbol) && isa (arg1, Const) && isdefined (arg1. val, sym. val)
278+ hasintersect (widenconst (sym), Symbol) || return Bottom
279+ if isa (sym, Const) && isa (sym. val, Symbol) && isa (arg1, Const) &&
280+ isdefined (arg1. val:: Module , sym. val:: Symbol )
280281 return Const (true )
281282 end
282283 elseif isa (sym, Const)
@@ -314,11 +315,8 @@ function isdefined_tfunc(@nospecialize(arg1), @nospecialize(sym))
314315 end
315316 end
316317 elseif isa (a1, Union)
317- t = Bottom
318- for u in uniontypes (a1)
319- t = tmerge (t, isdefined_tfunc (u, sym))
320- end
321- return t
318+ return tmerge (isdefined_tfunc (a1. a, sym),
319+ isdefined_tfunc (a1. b, sym))
322320 end
323321 return Bool
324322end
@@ -341,7 +339,7 @@ function sizeof_nothrow(@nospecialize(x))
341339 if t === Bottom
342340 # x must be an instance (not a Type) or is the Bottom type object
343341 x = widenconst (x)
344- return typeintersect (x, Type) === Union{}
342+ return ! hasintersect (x, Type)
345343 end
346344 x = unwrap_unionall (t)
347345 if isconcrete
@@ -599,9 +597,7 @@ function isa_tfunc(@nospecialize(v), @nospecialize(tt))
599597 if t === Bottom
600598 # check if t could be equivalent to typeof(Bottom), since that's valid in `isa`, but the set of `v` is empty
601599 # if `t` cannot have instances, it's also invalid on the RHS of isa
602- if typeintersect (widenconst (tt), Type) === Union{}
603- return Union{}
604- end
600+ hasintersect (widenconst (tt), Type) || return Union{}
605601 return Const (false )
606602 end
607603 if ! has_free_typevars (t)
@@ -617,7 +613,7 @@ function isa_tfunc(@nospecialize(v), @nospecialize(tt))
617613 end
618614 v = widenconst (v)
619615 isdispatchelem (v) && return Const (false )
620- if typeintersect (v, t) === Bottom
616+ if ! hasintersect (v, t)
621617 # similar to `isnotbrokensubtype` check above, `typeintersect(v, t)`
622618 # can't be trusted for kind types so we do an extra check here
623619 if ! iskindtype (v)
@@ -640,7 +636,7 @@ function subtype_tfunc(@nospecialize(a), @nospecialize(b))
640636 return Const (true )
641637 end
642638 else
643- if isexact_a || (b != = Bottom && typeintersect (a, b) === Union{} )
639+ if isexact_a || (b != = Bottom && ! hasintersect (a, b))
644640 return Const (false )
645641 end
646642 end
@@ -673,7 +669,7 @@ function fieldcount_noerror(@nospecialize t)
673669 return nothing
674670 end
675671 t = t:: DataType
676- elseif t == Union{}
672+ elseif t === Union{}
677673 return 0
678674 end
679675 if ! (t isa DataType)
@@ -1297,7 +1293,7 @@ function apply_type_tfunc(@nospecialize(headtypetype), @nospecialize args...)
12971293 end
12981294 else
12991295 if ! isType (ai)
1300- if ! isa (ai, Type) || typeintersect (ai, Type) != = Bottom || typeintersect (ai, TypeVar) != = Bottom
1296+ if ! isa (ai, Type) || hasintersect (ai, Type) || hasintersect (ai, TypeVar)
13011297 hasnonType = true
13021298 else
13031299 return Bottom
0 commit comments