Strip leading :: for globally qualified identifiers (#56033)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56033

Changelog: [Internal]

Currently, if the source code uses globally qualified identifiers, those will be kept in the snapshot without changes. Since in the output, everything is fully qualified, the leading `::` can be stripped from those.

Reviewed By: cortinico

Differential Revision: D95947334

fbshipit-source-id: 9592b00bd896679dda90ed56d32024b22752d2b7
This commit is contained in:
Jakub Piasecki
2026-03-11 00:17:04 -07:00
committed by meta-codesync[bot]
parent 7f6790bf79
commit 94f40e7591
2 changed files with 8 additions and 6 deletions
@@ -70,8 +70,8 @@ def _qualify_type_str_impl(type_str: str, scope: Scope, qualify_base: bool) -> s
return type_str
# Names starting with "::" are already globally qualified - skip re-qualification
if type_str.lstrip().startswith("::"):
return type_str
if type_str.lstrip().startswith("::") and qualify_base:
return type_str[2:]
# Handle template arguments first: qualify types inside angle brackets
angle_start = type_str.find("<")
@@ -105,7 +105,9 @@ def _qualify_type_str_impl(type_str: str, scope: Scope, qualify_base: bool) -> s
# Recursively qualify the suffix (handles nested templates, pointers, etc.)
qualified_suffix = (
_qualify_type_str_impl(suffix, scope, qualify_base) if suffix else ""
_qualify_type_str_impl(suffix, scope, qualify_base=False)
if suffix
else ""
)
return qualified_prefix + qualified_template + qualified_suffix
@@ -1,7 +1,7 @@
struct other::Consumer {
public ::test::inner::MyType create();
public void process(const ::test::inner::MyType& param);
public void processPtr(::test::inner::MyType* param);
public test::inner::MyType create();
public void process(const test::inner::MyType& param);
public void processPtr(test::inner::MyType* param);
}