Skip to content

Commit

Permalink
avoid limiting Type{Any} to Type (#51512)
Browse files Browse the repository at this point in the history
Fix #51510
  • Loading branch information
vtjnash authored Oct 5, 2023
1 parent 165f728 commit 25f510a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec
ct = Union{}
end
Qt = __limit_type_size(tt, ct, sources, depth + 1, 0)
Qt === Any && return Type
Qt === tt && return t
Qt === Any && return Type
# Can't form Type{<:Qt} just yet, without first make sure we limited the depth
# enough, since this moves Qt outside of Type for is_derived_type_from_any
Qt = __limit_type_size(tt, ct, sources, depth + 2, 0)
Expand Down
5 changes: 5 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ end
@test Core.Compiler.limit_type_size(Type{Union{Int,Type{Int}}}, Type{Type{Int}}, Union{}, 0, 0) == Type


@test Core.Compiler.limit_type_size(Type{Any}, Union{}, Union{}, 0, 0) ==
Core.Compiler.limit_type_size(Type{Any}, Any, Union{}, 0, 0) ==
Core.Compiler.limit_type_size(Type{Any}, Type, Union{}, 0, 0) ==
Type{Any}

# issue #43296 #43296
struct C43296{t,I} end
r43296(b) = r43296(typeof(b))
Expand Down

0 comments on commit 25f510a

Please sign in to comment.