mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 13:55:53 +01:00
Add support for most kinds of declarations to be declared and used as namespace members (#2575)
Support for global variables is still missing; they're a bit more tricky because they use a pattern to introduce their name. Prior to this change, explorer heavily relied on name comparisons to determine whether two declarations declare the same entity. Some of those instances are fixed in this PR, but more remain to be fixed, and some TODOs are added for some harder-to-fix instances.
This commit is contained in:
@@ -236,24 +236,24 @@ auto GetName(const Declaration& declaration)
|
||||
-> std::optional<std::string_view> {
|
||||
switch (declaration.kind()) {
|
||||
case DeclarationKind::NamespaceDeclaration:
|
||||
return cast<NamespaceDeclaration>(declaration).name();
|
||||
return cast<NamespaceDeclaration>(declaration).name().inner_name();
|
||||
case DeclarationKind::FunctionDeclaration:
|
||||
return cast<FunctionDeclaration>(declaration).name().inner_name();
|
||||
case DeclarationKind::DestructorDeclaration:
|
||||
return "destructor";
|
||||
case DeclarationKind::ClassDeclaration:
|
||||
return cast<ClassDeclaration>(declaration).name();
|
||||
return cast<ClassDeclaration>(declaration).name().inner_name();
|
||||
case DeclarationKind::MixinDeclaration: {
|
||||
return cast<MixinDeclaration>(declaration).name();
|
||||
return cast<MixinDeclaration>(declaration).name().inner_name();
|
||||
}
|
||||
case DeclarationKind::MixDeclaration: {
|
||||
return std::nullopt;
|
||||
}
|
||||
case DeclarationKind::ChoiceDeclaration:
|
||||
return cast<ChoiceDeclaration>(declaration).name();
|
||||
return cast<ChoiceDeclaration>(declaration).name().inner_name();
|
||||
case DeclarationKind::InterfaceDeclaration:
|
||||
case DeclarationKind::ConstraintDeclaration:
|
||||
return cast<ConstraintTypeDeclaration>(declaration).name();
|
||||
return cast<ConstraintTypeDeclaration>(declaration).name().inner_name();
|
||||
case DeclarationKind::VariableDeclaration:
|
||||
return cast<VariableDeclaration>(declaration).binding().name();
|
||||
case DeclarationKind::AssociatedConstantDeclaration:
|
||||
@@ -266,7 +266,7 @@ auto GetName(const Declaration& declaration)
|
||||
case DeclarationKind::SelfDeclaration:
|
||||
return SelfDeclaration::name();
|
||||
case DeclarationKind::AliasDeclaration: {
|
||||
return cast<AliasDeclaration>(declaration).name();
|
||||
return cast<AliasDeclaration>(declaration).name().inner_name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user