mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 18:51:09 +01:00
Type completion of facet types is separate from Identifying (#6385)
Identifying a facet type is an operation on a pair of (self type, facet type). It substitutes that self in as the `Self` of any require declarations in order to form the set of (self type, SpecificInterface) pairs that constitute the requirements of the IdentifiedFacetType. Currently we don't pass around any self type, and assume all require declarations are written against `Self` but this will change in the future. By contrast, type completion is done in the abstract and does not form specifics for the require declarations. The purpose of type completion is to enumerate the scopes where name lookup can occur and ensure they are completed. With this change, type completion is: - No longer built on top of identification for facet types. - Recursively ensures all `extend` scopes are complete since name lookup can find symbols in them. We add some test cases that demonstrate consistency between a resolving the specific of a generic class, and a generic interface/constraint, both used in a type position. In all cases, an invalid specific is not materialized for the type completion when the specific's arguments are used in a non-extend context. But they specific is materialized and checked for type completion when in an extend context (extend impl or extend require). Type completion itself does not need to recurse into named constraints or interfaces as the `extend require` declarations require the type to be complete immediately, just as for `extend impl` in a class. We had a test (`fail_incomplete_where.carbon`) with `impl as J where .Self impls K` and `J` is incomplete, which used to be diagnosed but no longer is, because we don't require non-extend interfaces to be complete in type completion, nor in identification. The test was trying to test the presence of rewrite constraints though, which it didn't even use. So we remove the diagnostic that we can't hit anymore and replaced it with a TODO, and add a test that should reach that TODO once qualified rewrite constraints work.
This commit is contained in:
@@ -814,6 +814,10 @@ auto StringifySpecific(const File& sem_ir, SpecificId specific_id)
|
||||
sem_ir.interfaces().Get(interface_decl.interface_id), specific_id);
|
||||
break;
|
||||
}
|
||||
case CARBON_KIND(RequireImplsDecl _): {
|
||||
step_stack.Push("require");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// TODO: Include the specific arguments here.
|
||||
step_stack.PushInstId(generic.decl_id);
|
||||
|
||||
Reference in New Issue
Block a user