mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Diagnose if a NodeIdOneOf argument isn't a typed node. (#6738)
This commit is contained in:
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user