mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 20:22:39 +00:00
This requires declared FacetTypes to hold NamedConstraintIds (along with a specific) that are named in an extend or impls requirement. We add support to stringify and formatter to display the named constraints in the facet type, and special case when a facet type contains a single extend named constraint, like we did for a single extend interface. This means that `RequireIndentifiedFacetType` can now fail, if the facet type contains a forward-declared named constraint. Add the appropriate diagnostics for each call to this function, and note the ones that should change to `RequireCompleteFacetType` in the future with TODOs. We also add tests for using facet types that can or can't be identified, or completed, with named constraints in them.
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_SEM_IR_SPECIFIC_INTERFACE_H_
|
|
#define CARBON_TOOLCHAIN_SEM_IR_SPECIFIC_INTERFACE_H_
|
|
|
|
#include "toolchain/base/canonical_value_store.h"
|
|
#include "toolchain/sem_ir/ids.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
// A pair of an interface and a specific for that interface.
|
|
struct SpecificInterface {
|
|
using DiagnosticType = Diagnostics::TypeInfo<std::string>;
|
|
|
|
static const SpecificInterface None;
|
|
|
|
InterfaceId interface_id;
|
|
SpecificId specific_id;
|
|
|
|
friend auto operator==(const SpecificInterface& lhs,
|
|
const SpecificInterface& rhs) -> bool = default;
|
|
};
|
|
|
|
constexpr SpecificInterface SpecificInterface::None = {
|
|
.interface_id = InterfaceId::None, .specific_id = SpecificId::None};
|
|
|
|
using SpecificInterfaceStore =
|
|
CanonicalValueStore<SpecificInterfaceId, SpecificInterface>;
|
|
|
|
} // namespace Carbon::SemIR
|
|
|
|
#endif // CARBON_TOOLCHAIN_SEM_IR_SPECIFIC_INTERFACE_H_
|