mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user