Diagnose if a NodeIdOneOf argument isn't a typed node. (#6738)

This commit is contained in:
Geoff Romer
2026-02-13 22:44:23 +00:00
committed by GitHub
parent 3c324e4877
commit b3d57aff7a
+12 -1
View File
@@ -113,9 +113,20 @@ using AnyRequirementId = NodeIdInCategory<NodeCategory::Requirement>;
using AnyNonExprNameId = NodeIdInCategory<NodeCategory::NonExprName>;
using AnyPackageNameId = NodeIdInCategory<NodeCategory::PackageName>;
namespace Internal {
template <typename T>
concept IsNodeKind = std::same_as<std::remove_cvref_t<T>, NodeKind> ||
std::same_as<std::remove_cvref_t<T>, NodeKind::Definition>;
template <typename T>
concept IsTypedNode = requires {
{ T::Kind } -> IsNodeKind;
};
} // namespace Internal
// NodeId with kind that matches one of the `T::Kind`s.
template <typename... T>
requires(sizeof...(T) >= 2)
requires(sizeof...(T) >= 2 && (Internal::IsTypedNode<T> && ...))
struct NodeIdOneOf : public NodeId {
private:
// True if `OtherT` is one of `T`.