mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 11:58:12 +00:00
When forming an IdentifiedFacetType, we collect interfaces named by require decls in named constraints that the facet type refers to. These interfaces come with a specific, but the require decl is inside an named constraint which may be generic. So we need the specific being applied to the containing named constraint to also be applied to the require decl and its target interfaces. This uncovered that the facet type in require decls was not being imported correctly, as it was not being attached to the require decl's generic. This is fixed by making import of RequireImplsDecl multiphase, so that the decl instruction exists before we resolve the facet type within it. And by pointing the generic importing machinery to the RequireImplsDecl, and from there to the RequireImpls structure to get the generic id. Then `ImplStore::GetOrAddLookupBucket` can use an IdentifiedFacetType to correctly get the interface being impl'd, both in the local and the imported named constraint case. Which allows us to correctly diagnose redeclarations in the impl file of an impl of an interface through a named constraint. And to correctly _not_ diagnose them when the specific in the generic named constraint differs from other decls.