Skip to content

Commit e2ed527

Browse files
jckingcopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 933914348
1 parent 071fca0 commit e2ed527

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

checker/internal/type_checker_impl.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class ResolveVisitor : public AstVisitorBase {
199199
struct AttributeResolution {
200200
const VariableDecl* decl;
201201
bool requires_disambiguation;
202+
bool local;
202203
};
203204

204205
ResolveVisitor(NamespaceGenerator namespace_generator,
@@ -1001,7 +1002,7 @@ void ResolveVisitor::ResolveSimpleIdentifier(const Expr& expr,
10011002
const VariableDecl* local_decl = LookupLocalIdentifier(name);
10021003

10031004
if (local_decl != nullptr && !absl::StartsWith(name, ".")) {
1004-
attributes_[&expr] = {local_decl, false};
1005+
attributes_[&expr] = {local_decl, false, /*local=*/true};
10051006
types_[&expr] =
10061007
inference_context_->InstantiateTypeParams(local_decl->type());
10071008
return;
@@ -1016,8 +1017,13 @@ void ResolveVisitor::ResolveSimpleIdentifier(const Expr& expr,
10161017
});
10171018

10181019
if (decl != nullptr) {
1019-
attributes_[&expr] = {decl,
1020-
/* requires_disambiguation= */ local_decl != nullptr};
1020+
attributes_[&expr] = {
1021+
decl,
1022+
/* requires_disambiguation= */ local_decl != nullptr,
1023+
// There is some oddity here, `.` prefixed idents should never be local.
1024+
// So LookupLocalIdentifier above should never return a valid decl.
1025+
// Perhaps this is a refactor holdover?
1026+
/*local=*/false};
10211027
types_[&expr] = inference_context_->InstantiateTypeParams(decl->type());
10221028
return;
10231029
}
@@ -1072,9 +1078,14 @@ void ResolveVisitor::ResolveQualifiedIdentifier(
10721078
root = &root->select_expr().operand();
10731079
}
10741080

1075-
attributes_[root] = {decl,
1076-
/* requires_disambiguation= */ decl != local_decl &&
1077-
local_decl != nullptr};
1081+
attributes_[root] = {
1082+
decl,
1083+
/* requires_disambiguation= */ decl != local_decl &&
1084+
local_decl != nullptr,
1085+
// There is some oddity here, `.` prefixed idents should never be local.
1086+
// So LookupLocalIdentifier above should never return a valid decl.
1087+
// Perhaps this is a refactor holdover?
1088+
/*local=*/local_decl == decl};
10781089
types_[root] = inference_context_->InstantiateTypeParams(decl->type());
10791090

10801091
// fix-up select operations that were deferred.

0 commit comments

Comments
 (0)