Skip to content

Commit 25f510a

Browse files
authored
avoid limiting Type{Any} to Type (#51512)
Fix #51510
1 parent 165f728 commit 25f510a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/compiler/typelimits.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec
135135
ct = Union{}
136136
end
137137
Qt = __limit_type_size(tt, ct, sources, depth + 1, 0)
138-
Qt === Any && return Type
139138
Qt === tt && return t
139+
Qt === Any && return Type
140140
# Can't form Type{<:Qt} just yet, without first make sure we limited the depth
141141
# enough, since this moves Qt outside of Type for is_derived_type_from_any
142142
Qt = __limit_type_size(tt, ct, sources, depth + 2, 0)

test/compiler/inference.jl

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ end
121121
@test Core.Compiler.limit_type_size(Type{Union{Int,Type{Int}}}, Type{Type{Int}}, Union{}, 0, 0) == Type
122122

123123

124+
@test Core.Compiler.limit_type_size(Type{Any}, Union{}, Union{}, 0, 0) ==
125+
Core.Compiler.limit_type_size(Type{Any}, Any, Union{}, 0, 0) ==
126+
Core.Compiler.limit_type_size(Type{Any}, Type, Union{}, 0, 0) ==
127+
Type{Any}
128+
124129
# issue #43296 #43296
125130
struct C43296{t,I} end
126131
r43296(b) = r43296(typeof(b))

0 commit comments

Comments
 (0)