mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 12:54:58 +01:00
* Implement ignoring the difference between `Self as` and `as`, as well as `where` clauses at the end of an `impl` declaration when checking whether `impl` declarations match, from #3763. * Allow impl declarations with different constraint ids to match, as long as the facet type of the constraint has the same interface_id and specific_id. * Add some TODOs reflecting future facet type resolution. --------- Co-authored-by: Josh L <josh11b@users.noreply.github.com>
34 lines
1.3 KiB
C++
34 lines
1.3 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
|
|
|
|
#include "toolchain/sem_ir/impl.h"
|
|
|
|
#include "toolchain/sem_ir/file.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
auto ImplStore::GetOrAddLookupBucket(const Impl& impl) -> LookupBucketRef {
|
|
auto self_id = sem_ir_.constant_values().GetConstantInstId(impl.self_id);
|
|
InterfaceId interface_id = InterfaceId::Invalid;
|
|
SpecificId specific_id = SpecificId::Invalid;
|
|
auto facet_type_id = TypeId::ForTypeConstant(
|
|
sem_ir_.constant_values().Get(impl.constraint_id));
|
|
if (auto facet_type =
|
|
sem_ir_.types().TryGetAs<SemIR::FacetType>(facet_type_id)) {
|
|
const SemIR::FacetTypeInfo& facet_type_info =
|
|
sem_ir_.facet_types().Get(facet_type->facet_type_id);
|
|
if (auto interface_type = facet_type_info.TryAsSingleInterface()) {
|
|
interface_id = interface_type->interface_id;
|
|
specific_id = interface_type->specific_id;
|
|
}
|
|
}
|
|
return LookupBucketRef(
|
|
*this, lookup_
|
|
.Insert(std::tuple{self_id, interface_id, specific_id},
|
|
[] { return ImplOrLookupBucketId::Invalid; })
|
|
.value());
|
|
}
|
|
|
|
} // namespace Carbon::SemIR
|