deduce.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_DEDUCE_H_
  5. #define CARBON_TOOLCHAIN_CHECK_DEDUCE_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::Check {
  9. // Deduces the generic arguments to use in a call to a generic.
  10. auto DeduceGenericCallArguments(
  11. Context& context, SemIR::LocId loc_id, SemIR::GenericId generic_id,
  12. SemIR::SpecificId enclosing_specific_id, SemIR::InstId self_type_id,
  13. SemIR::InstBlockId implicit_params_id, SemIR::InstBlockId params_id,
  14. SemIR::InstId self_id, llvm::ArrayRef<SemIR::InstId> arg_ids)
  15. -> SemIR::SpecificId;
  16. // Data from the `Impl` that is used by deduce.
  17. //
  18. // We don't use a reference to an `Impl` as deduction can invalidate the
  19. // reference by causing impl declarations to be imported from `Core` during
  20. // conversion.
  21. struct DeduceImpl {
  22. SemIR::InstId self_id;
  23. SemIR::GenericId generic_id;
  24. SemIR::SpecificId specific_id;
  25. };
  26. // Deduces the impl arguments to use in a use of a parameterized impl. Returns
  27. // `None` if deduction fails.
  28. auto DeduceImplArguments(Context& context, SemIR::LocId loc_id, DeduceImpl impl,
  29. SemIR::ConstantId self_id,
  30. SemIR::SpecificId constraint_specific_id)
  31. -> SemIR::SpecificId;
  32. } // namespace Carbon::Check
  33. #endif // CARBON_TOOLCHAIN_CHECK_DEDUCE_H_