Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid limiting Type{Any} to Type #51512

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading