Don't requalify already globally qualified identifiers (#55847)

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

Changelog: [Internal]

Disables name qualification on already globally qualified identifiers.

Reviewed By: cortinico

Differential Revision: D94901503

fbshipit-source-id: 22206b454c37e7e061abf34d64839f79c82eea1f
This commit is contained in:
Jakub Piasecki authored and meta-codesync[bot] committed 2026-03-03 01:00:16 -08:00
1 parent 1fdddb09fe
commit 11072438f1
4 files changed
+45 -1

No files matched your search

+3 -1
View File
@@ -87,7 +87,9 @@ def resolve_linked_text_name(
refid = getattr(part.value, "refid", None)
if refid and not in_string:
ns = extract_namespace_from_refid(refid)
if ns and not text.startswith(ns):
# Skip re-qualification if text is already globally qualified
# (starts with "::") - it's already an absolute path
if ns and not text.startswith(ns) and not text.startswith("::"):
# The text may already start with a trailing portion of
# the namespace. For example ns="facebook::react::HighResDuration"
# and text="HighResDuration::zero". We need to find the
@@ -31,6 +31,10 @@ def qualify_type_str(type_str: str, scope: Scope) -> str:
if not type_str:
return type_str
# Names starting with "::" are already globally qualified - skip re-qualification
if type_str.lstrip().startswith("::"):
return type_str
# Handle template arguments first: qualify types inside angle brackets
angle_start = type_str.find("<")
if angle_start != -1:
@@ -0,0 +1,10 @@
struct other::Consumer {
public ::test::inner::MyType create();
public void process(const ::test::inner::MyType & param);
public void processPtr(::test::inner::MyType * param);
}
struct test::inner::MyType {
public int value;
}
@@ -0,0 +1,28 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
namespace test {
namespace inner {
struct MyType {
int value;
};
} // namespace inner
} // namespace test
namespace other {
struct Consumer {
void process(const ::test::inner::MyType &param);
void processPtr(::test::inner::MyType *param);
::test::inner::MyType create();
};
} // namespace other