From 248d38e5c1791ae02ecba0a1a012be82ccae9abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 18 Mar 2026 09:29:02 -0700 Subject: [PATCH] Fix qualification of enum values in template specialization args (#56070) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56070 Changelog: [Internal] Fixes qualification of unscoped enum values used as template specialization arguments. Reviewed By: cipolleschi Differential Revision: D96279462 fbshipit-source-id: d151b069124b352451964a31da0385744d21013f --- scripts/cxx-api/parser/scope.py | 7 +++- .../snapshot.api | 19 +++++++++++ .../test.h | 32 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/test.h diff --git a/scripts/cxx-api/parser/scope.py b/scripts/cxx-api/parser/scope.py index b4cc776cd05..615af32a196 100644 --- a/scripts/cxx-api/parser/scope.py +++ b/scripts/cxx-api/parser/scope.py @@ -396,8 +396,13 @@ class Scope(Generic[ScopeKindT]): elif any( m.name == base_name and not isinstance(m, FriendMember) for m in current_scope._members + ) or any( + any(m.name == base_name for m in inner._members) + for inner in current_scope.inner_scopes.values() + if isinstance(inner.kind, EnumScopeKind) ): - # Found as a member, assume following segments exist in the scope + # Found as a member (or as an unscoped enum value accessible + # from the parent scope), assume following segments exist prefix = "::".join(matched_segments) suffix = "::".join(path[i:]) anchor_prefix = anchor_scope.get_qualified_name() diff --git a/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/snapshot.api b/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/snapshot.api new file mode 100644 index 00000000000..690ad506546 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/snapshot.api @@ -0,0 +1,19 @@ +struct test::Event { +} + +enum test::Event::Type { + NodeAllocation, + NodeDeallocation, +} + +template +struct test::Event::TypedData { +} + +struct test::Event::TypedData { + public int config; +} + +struct test::Event::TypedData { + public int config; +} diff --git a/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/test.h b/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/test.h new file mode 100644 index 00000000000..b1c42974c79 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_qualify_enum_value_in_template_specialization/test.h @@ -0,0 +1,32 @@ +/* + * 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 { + +struct Event { + enum Type { + NodeAllocation, + NodeDeallocation, + }; + + template + struct TypedData {}; +}; + +template <> +struct Event::TypedData { + int config; +}; + +template <> +struct Event::TypedData { + int config; +}; + +} // namespace test