Skip to content

Commit 3fe9c99

Browse files
committed
inference: fix typeof-tfunc impl
1 parent 58a0016 commit 3fe9c99

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

base/compiler/tfuncs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function typeof_tfunc(@nospecialize(t))
450450
a = widenconst(typeof_tfunc(t.a))
451451
b = widenconst(typeof_tfunc(t.b))
452452
return Union{a, b}
453-
elseif isa(t, TypeVar) && !(Any <: t.ub)
453+
elseif isa(t, TypeVar) && !(Any === t.ub)
454454
return typeof_tfunc(t.ub)
455455
elseif isa(t, UnionAll)
456456
u = unwrap_unionall(t)

test/compiler/inference.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,10 @@ using Core.Compiler: typeof_tfunc
13531353
@test typeof_tfunc(Type{<:Array}) === DataType
13541354
@test typeof_tfunc(Array{Int}) == Type{Array{Int,N}} where N
13551355
@test typeof_tfunc(AbstractArray{Int}) == Type{<:AbstractArray{Int,N}} where N
1356+
@test typeof_tfunc(Union{<:T, <:Real} where T<:Complex) == Union{Type{Complex{T}} where T<:Real, Type{<:Real}}
1357+
1358+
f_typeof_tfunc(x) = typeof(x)
1359+
@test Base.return_types(f_typeof_tfunc, (Union{<:T, Int} where T<:Complex,)) == Any[Union{Type{Int}, Type{Complex{T}} where T<:Real}]
13561360

13571361
function f23024(::Type{T}, ::Int) where T
13581362
1 + 1

0 commit comments

Comments
 (0)