Skip to content

Commit 934cc51

Browse files
vtjnashKristofferC
authored andcommitted
inference: fix typeof-tfunc impl (#31405)
(cherry picked from commit 604c9b2)
1 parent ef22206 commit 934cc51

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ function typeof_tfunc(@nospecialize(t))
392392
a = widenconst(typeof_tfunc(t.a))
393393
b = widenconst(typeof_tfunc(t.b))
394394
return Union{a, b}
395-
elseif isa(t, TypeVar) && !(Any <: t.ub)
395+
elseif isa(t, TypeVar) && !(Any === t.ub)
396396
return typeof_tfunc(t.ub)
397397
elseif isa(t, UnionAll)
398398
return rewrap_unionall(widenconst(typeof_tfunc(unwrap_unionall(t))), t)

test/compiler/compiler.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,11 @@ let egal_tfunc
13391339
@test egal_tfunc(Union{Int64, Float64}, AbstractArray) === Const(false)
13401340
end
13411341

1342+
@test typeof_tfunc(Union{<:T, <:Real} where T<:Complex) == Union{Type{Complex{T}} where T<:Real, Type{<:Real}}
1343+
1344+
f_typeof_tfunc(x) = typeof(x)
1345+
@test Base.return_types(f_typeof_tfunc, (Union{<:T, Int} where T<:Complex,)) == Any[Union{Type{Int}, Type{Complex{T}} where T<:Real}]
1346+
13421347
function f23024(::Type{T}, ::Int) where T
13431348
1 + 1
13441349
end

0 commit comments

Comments
 (0)