Allow extend adapt of non-class types. (#4544)

Stop rejecting `extend adapt` of non-class types such as struct and
tuple. These don't actually work just yet because name lookup into
struct and tuple types is a special case that doesn't handle adapters,
but this gets us a bit closer.

This also slightly improves error recovery for name lookup into an
invalid scope.
This commit is contained in:
Richard Smith
2024-11-18 16:01:44 +00:00
committed by GitHub
parent bc395eb889
commit 145f878ce8
17 changed files with 269 additions and 36 deletions
+6
View File
@@ -481,6 +481,12 @@ auto Context::AppendLookupScopesForConstant(
}
return true;
}
if (base_const_id == SemIR::ConstantId::Error) {
// Lookup into this scope should fail without producing an error.
scopes->push_back(LookupScope{.name_scope_id = SemIR::NameScopeId::Invalid,
.specific_id = SemIR::SpecificId::Invalid});
return true;
}
// TODO: Per the design, if `base_id` is any kind of type, then lookup should
// treat it as a name scope, even if it doesn't have members. For example,
// `(i32*).X` should fail because there's no name `X` in `i32*`, not because