Skip to content

Commit 132dd73

Browse files
vtjnashKristofferC
authored andcommitted
inference: fix typeof-tfunc impl (#31405)
(cherry picked from commit 604c9b2)
1 parent 0bc6c5d commit 132dd73

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/tfuncs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ function typeof_tfunc(@nospecialize(t))
441441
a = widenconst(typeof_tfunc(t.a))
442442
b = widenconst(typeof_tfunc(t.b))
443443
return Union{a, b}
444-
elseif isa(t, TypeVar) && !(Any <: t.ub)
444+
elseif isa(t, TypeVar) && !(Any === t.ub)
445445
return typeof_tfunc(t.ub)
446446
elseif isa(t, UnionAll)
447447
return rewrap_unionall(widenconst(typeof_tfunc(unwrap_unionall(t))), t)

test/compiler/inference.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,11 @@ let egal_tfunc
13401340
@test egal_tfunc(Union{Int64, Float64}, AbstractArray) === Const(false)
13411341
end
13421342

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

0 commit comments

Comments
 (0)