impl_lookup.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_IMPL_LOOKUP_H_
  5. #define CARBON_TOOLCHAIN_CHECK_IMPL_LOOKUP_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::Check {
  9. // Looks up the witnesses to use for a type value or facet value, and a facet
  10. // type naming a set of interfaces required to be implemented for that type, as
  11. // well as possible constraints on those interfaces.
  12. //
  13. // N.B. In the future, `TypeType` will become a facet type, at which point type
  14. // values will also be facet values.
  15. //
  16. // The return value is one of:
  17. // - An InstBlockId value, containing an `ImplWitness` instruction for each
  18. // required interface in the `query_facet_type_const_id`. This verifies the
  19. // facet type is satisfied for the type in `type_const_id`, and provides a
  20. // witness for accessing the impl of each interface.
  21. //
  22. // - `InstBlockId::None`, indicating lookup failed for at least one required
  23. // interface in the `query_facet_type_const_id`. The facet type is not
  24. // satisfied for the type in `type_const_id`. This represents lookup failure,
  25. // but is not an error, so no diagnostic is emitted.
  26. //
  27. // - An error value, indicating the program is invalid and a diagonstic has been
  28. // produced, either in this function or before.
  29. auto LookupImplWitness(Context& context, SemIR::LocId loc_id,
  30. SemIR::ConstantId query_self_const_id,
  31. SemIR::ConstantId query_facet_type_const_id)
  32. -> SemIR::InstBlockIdOrError;
  33. } // namespace Carbon::Check
  34. #endif // CARBON_TOOLCHAIN_CHECK_IMPL_LOOKUP_H_