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

use _NAMEDTUPLE_NAME instead of NamedTuple_typename [NFC] #47057

Merged
merged 1 commit into from
Oct 5, 2022
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/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft)

tti0 = widenconst(typ)
tti = unwrap_unionall(tti0)
if isa(tti, DataType) && tti.name === NamedTuple_typename
if isa(tti, DataType) && tti.name === _NAMEDTUPLE_NAME
# A NamedTuple iteration is the same as the iteration of its Tuple parameter:
# compute a new `tti == unwrap_unionall(tti0)` based on that Tuple type
tti = unwraptv(tti.parameters[2])
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ function rewrite_apply_exprargs!(
end
else
ti = widenconst(def_type)::DataType # checked by `is_valid_type_for_apply_rewrite`
if ti.name === NamedTuple_typename
if ti.name === _NAMEDTUPLE_NAME
ti = ti.parameters[2]::DataType # checked by `is_valid_type_for_apply_rewrite`
end
for p in ti.parameters
Expand Down Expand Up @@ -1069,7 +1069,7 @@ function is_valid_type_for_apply_rewrite(@nospecialize(typ), params::Optimizatio
return true
end
typ = widenconst(typ)
if isa(typ, DataType) && typ.name === NamedTuple_typename
if isa(typ, DataType) && typ.name === _NAMEDTUPLE_NAME
typ = typ.parameters[2]
typ = unwraptv(typ)
end
Expand Down
2 changes: 0 additions & 2 deletions base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

@nospecialize

const _NAMEDTUPLE_NAME = NamedTuple.body.body.name

const INT_INF = typemax(Int) # integer infinity

const N_IFUNC = reinterpret(Int32, have_fma) + 1
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/typeutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ end
# (therefore also a lower bound on the number of fields)
function datatype_min_ninitialized(t::DataType)
isabstracttype(t) && return 0
if t.name === NamedTuple_typename
if t.name === _NAMEDTUPLE_NAME
names, types = t.parameters[1], t.parameters[2]
if names isa Tuple
return length(names)
Expand Down
6 changes: 3 additions & 3 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ function resolve(g::GlobalRef; force::Bool=false)
return g
end

const NamedTuple_typename = NamedTuple.body.body.name
const _NAMEDTUPLE_NAME = NamedTuple.body.body.name

function _fieldnames(@nospecialize t)
if t.name === NamedTuple_typename
if t.name === _NAMEDTUPLE_NAME
if t.parameters[1] isa Tuple
return t.parameters[1]
else
Expand Down Expand Up @@ -797,7 +797,7 @@ function fieldcount(@nospecialize t)
if !(t isa DataType)
throw(TypeError(:fieldcount, DataType, t))
end
if t.name === NamedTuple_typename
if t.name === _NAMEDTUPLE_NAME
names, types = t.parameters[1], t.parameters[2]
if names isa Tuple
return length(names)
Expand Down
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@ function dump(io::IOContext, x::DataType, n::Int, indent)
tvar_io = IOContext(tvar_io, :unionall_env => tparam)
end
end
if x.name === NamedTuple_typename && !(x.parameters[1] isa Tuple)
if x.name === _NAMEDTUPLE_NAME && !(x.parameters[1] isa Tuple)
# named tuple type with unknown field names
return
end
Expand Down