Skip to content

Commit 7894488

Browse files
j-piaseckizoontek
authored andcommitted
Don't requalify already globally qualified identifiers (react#55847)
Summary: Pull Request resolved: react#55847 Changelog: [Internal] Disables name qualification on already globally qualified identifiers. Reviewed By: cortinico Differential Revision: D94901503 fbshipit-source-id: 22206b454c37e7e061abf34d64839f79c82eea1f
1 parent 9a75f11 commit 7894488

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

scripts/cxx-api/parser/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def resolve_linked_text_name(
8787
refid = getattr(part.value, "refid", None)
8888
if refid and not in_string:
8989
ns = extract_namespace_from_refid(refid)
90-
if ns and not text.startswith(ns):
90+
# Skip re-qualification if text is already globally qualified
91+
# (starts with "::") - it's already an absolute path
92+
if ns and not text.startswith(ns) and not text.startswith("::"):
9193
# The text may already start with a trailing portion of
9294
# the namespace. For example ns="facebook::react::HighResDuration"
9395
# and text="HighResDuration::zero". We need to find the

scripts/cxx-api/parser/utils/type_qualification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def qualify_type_str(type_str: str, scope: Scope) -> str:
3131
if not type_str:
3232
return type_str
3333

34+
# Names starting with "::" are already globally qualified - skip re-qualification
35+
if type_str.lstrip().startswith("::"):
36+
return type_str
37+
3438
# Handle template arguments first: qualify types inside angle brackets
3539
angle_start = type_str.find("<")
3640
if angle_start != -1:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct other::Consumer {
2+
public ::test::inner::MyType create();
3+
public void process(const ::test::inner::MyType & param);
4+
public void processPtr(::test::inner::MyType * param);
5+
}
6+
7+
8+
struct test::inner::MyType {
9+
public int value;
10+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
namespace test {
11+
namespace inner {
12+
13+
struct MyType {
14+
int value;
15+
};
16+
17+
} // namespace inner
18+
} // namespace test
19+
20+
namespace other {
21+
22+
struct Consumer {
23+
void process(const ::test::inner::MyType &param);
24+
void processPtr(::test::inner::MyType *param);
25+
::test::inner::MyType create();
26+
};
27+
28+
} // namespace other

0 commit comments

Comments
 (0)