From 375cc2438aa529f82f2cc93d5099d3de54b07111 Mon Sep 17 00:00:00 2001 From: pennae Date: Mon, 26 Feb 2024 15:33:52 +0100 Subject: [PATCH] remove ExprAttrs::AttrDef::inherited it's no longer widely used and has a rather confusing meaning now that inherit-from is handled very differently. --- src/libexpr/eval.cc | 2 +- src/libexpr/nixexpr.hh | 2 -- src/libexpr/parser-state.hh | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index a353571af..2e7c8207c 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1220,7 +1220,7 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v) Displacement displ = 0; for (auto & i : attrs) { Value * vAttr; - if (hasOverrides && !i.second.inherited()) { + if (hasOverrides && i.second.kind != AttrDef::Kind::Inherited) { vAttr = state.allocValue(); mkThunk(*vAttr, *i.second.chooseByKind(&env2, &env, inheritEnv), i.second.e); } else diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 4bb2ee2f9..2390c4286 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -189,8 +189,6 @@ struct ExprAttrs : Expr : kind(kind), e(e), pos(pos) { }; AttrDef() { }; - bool inherited() const { return kind == Kind::Inherited; } - template const T & chooseByKind(const T & plain, const T & inherited, const T & inheritedFrom) const { diff --git a/src/libexpr/parser-state.hh b/src/libexpr/parser-state.hh index 9aa18a0ae..34aef661f 100644 --- a/src/libexpr/parser-state.hh +++ b/src/libexpr/parser-state.hh @@ -89,7 +89,7 @@ inline void ParserState::addAttr(ExprAttrs * attrs, AttrPath && attrPath, Expr * if (i->symbol) { ExprAttrs::AttrDefs::iterator j = attrs->attrs.find(i->symbol); if (j != attrs->attrs.end()) { - if (!j->second.inherited()) { + if (j->second.kind != ExprAttrs::AttrDef::Kind::Inherited) { ExprAttrs * attrs2 = dynamic_cast(j->second.e); if (!attrs2) dupAttr(attrPath, pos, j->second.pos); attrs = attrs2;