Distinguish between the symbolic .Self value for an associated constant and the value found when referencing one. (#2348)

Within the type of an associated constant, references to `.Self` should resolve symbolically to that associated constant as a `GenericBinding` so that it can be substituted for the actual value when using its type. However, when the associated constant is referenced from elsewhere in the same interface, the value we want is a symbolic value naming the constant as a member of `Self`.
This commit is contained in:
Richard Smith
2022-10-25 12:29:51 -07:00
committed by GitHub
parent f1e36a50ca
commit 5c3f48b0fb
6 changed files with 25 additions and 22 deletions
+4 -3
View File
@@ -77,8 +77,7 @@ static auto AddExposedNames(const Declaration& declaration,
case DeclarationKind::AssociatedConstantDeclaration: {
const auto& let = cast<AssociatedConstantDeclaration>(declaration);
if (let.binding().name() != AnonymousName) {
CARBON_RETURN_IF_ERROR(
enclosing_scope.Add(let.binding().name(), &let.binding()));
CARBON_RETURN_IF_ERROR(enclosing_scope.Add(let.binding().name(), &let));
}
break;
}
@@ -666,7 +665,9 @@ static auto ResolveNames(Declaration& declaration, StaticScope& enclosing_scope,
}
case DeclarationKind::AssociatedConstantDeclaration: {
auto& let = cast<AssociatedConstantDeclaration>(declaration);
CARBON_RETURN_IF_ERROR(ResolveNames(let.binding(), enclosing_scope));
StaticScope constant_scope;
constant_scope.AddParent(&enclosing_scope);
CARBON_RETURN_IF_ERROR(ResolveNames(let.binding(), constant_scope));
break;
}