Skip to content

Commit aa48848

Browse files
committed
fix 9765 test
1 parent 8705622 commit aa48848

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

base/compiler/tfuncs.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,17 @@ add_tfunc(typeassert, 2, 2,
389389
end, 4)
390390
add_tfunc(isa, 2, 2,
391391
function (@nospecialize(v), @nospecialize(t))
392+
_t = t
392393
t, isexact = instanceof_tfunc(t)
393394
if !has_free_typevars(t)
394395
if t === Bottom
395-
return Const(false)
396+
# we make this check because `t` could be `Bottom` when `_t` is e.g.
397+
# `Type{Union{}}`, in which case we want to return `Const(false)`
398+
if typeintersect(_t, Type) === Bottom && _t !== typeof(Bottom)
399+
return Bottom
400+
else
401+
return Const(false)
402+
end
396403
elseif v t
397404
if isexact && isnotbrokensubtype(v, t)
398405
return Const(true)

test/compiler/compiler.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1179,17 +1179,17 @@ let isa_tfunc = Core.Compiler.T_FFUNC_VAL[
11791179
@test isa_tfunc(Array{Real}, Type{AbstractArray{Int}}) === Const(false)
11801180
@test isa_tfunc(Array{Real, 2}, Const(AbstractArray{Real, 2})) === Const(true)
11811181
@test isa_tfunc(Array{Real, 2}, Const(AbstractArray{Int, 2})) === Const(false)
1182-
@test isa_tfunc(DataType, Int) === Const(false)
1182+
@test isa_tfunc(DataType, Int) === Union{}
11831183
@test isa_tfunc(DataType, Const(Type{Int})) === Bool
11841184
@test isa_tfunc(DataType, Const(Type{Array})) === Bool
11851185
@test isa_tfunc(UnionAll, Const(Type{Int})) === Bool # could be improved
11861186
@test isa_tfunc(UnionAll, Const(Type{Array})) === Bool
11871187
@test isa_tfunc(Union, Const(Union{Float32, Float64})) === Bool
11881188
@test isa_tfunc(Union, Type{Union}) === Const(true)
11891189
@test isa_tfunc(typeof(Union{}), Const(Int)) === Const(false) # any result is ok
1190-
@test isa_tfunc(typeof(Union{}), Const(Union{})) === Const(false)
1190+
@test isa_tfunc(typeof(Union{}), Const(Union{})) === Union{}
11911191
@test isa_tfunc(typeof(Union{}), typeof(Union{})) === Const(false)
1192-
@test isa_tfunc(typeof(Union{}), Union{}) === Const(false) # any result is ok
1192+
@test isa_tfunc(typeof(Union{}), Union{}) === Union{} # any result is ok
11931193
@test isa_tfunc(typeof(Union{}), Type{typeof(Union{})}) === Const(true)
11941194
@test isa_tfunc(typeof(Union{}), Const(typeof(Union{}))) === Const(true)
11951195
let c = Conditional(Core.SlotNumber(0), Const(Union{}), Const(Union{}))
@@ -1204,7 +1204,7 @@ let isa_tfunc = Core.Compiler.T_FFUNC_VAL[
12041204
@test isa_tfunc(Val{1}, Type{Val{T}} where T) === Bool
12051205
@test isa_tfunc(Val{1}, DataType) === Bool
12061206
@test isa_tfunc(Any, Const(Any)) === Const(true)
1207-
@test isa_tfunc(Any, Union{}) === Const(false) # any result is ok
1207+
@test isa_tfunc(Any, Union{}) === Union{} # any result is ok
12081208
@test isa_tfunc(Any, Type{Union{}}) === Const(false)
12091209
@test isa_tfunc(Union{Int64, Float64}, Type{Real}) === Const(true)
12101210
@test isa_tfunc(Union{Int64, Float64}, Type{Integer}) === Bool

0 commit comments

Comments
 (0)