Skip to content

Commit 6e9faab

Browse files
committed
fix #31803, covariance handling in fieldtype_tfunc
1 parent d71310e commit 6e9faab

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ function _fieldtype_tfunc(@nospecialize(s), exact::Bool, @nospecialize(name))
939939
ft = ftypes[fld]
940940
end
941941

942-
exactft = exact || !has_free_typevars(ft)
942+
exactft = exact || (!has_free_typevars(ft) && u.name !== Tuple.name)
943943
ft = rewrap_unionall(ft, s)
944944
if exactft
945945
if issingletontype(ft)

test/compiler/inference.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ let fieldtype_tfunc = Core.Compiler.fieldtype_tfunc,
621621
@test fieldtype_tfunc(Union{Type{Base.RefValue{<:Real}}, Type{Int32}}, Const(:x)) == Const(Real)
622622
@test fieldtype_tfunc(Const(Union{Base.RefValue{<:Real}, Type{Int32}}), Const(:x)) == Type
623623
@test fieldtype_tfunc(Type{Union{Base.RefValue{T}, Type{Int32}}} where {T<:Real}, Const(:x)) == Type
624+
@test fieldtype_tfunc(Type{<:Tuple}, Const(1)) == Type
624625
@test fieldtype_nothrow(Type{Base.RefValue{<:Real}}, Const(:x))
625626
@test !fieldtype_nothrow(Type{Union{}}, Const(:x))
626627
@test !fieldtype_nothrow(Union{Type{Base.RefValue{T}}, Int32} where {T<:Real}, Const(:x))

0 commit comments

Comments
 (0)