From 25f510a34523922f45f9d676d156123959a29f47 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 5 Oct 2023 01:30:14 -0400 Subject: [PATCH] avoid limiting Type{Any} to Type (#51512) Fix #51510 --- base/compiler/typelimits.jl | 2 +- test/compiler/inference.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/compiler/typelimits.jl b/base/compiler/typelimits.jl index 44ddbf8dcba38..dc68f026e6b8f 100644 --- a/base/compiler/typelimits.jl +++ b/base/compiler/typelimits.jl @@ -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) diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 52309744b4a05..ca3e20b552470 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -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))