mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Qualify conversion operator type names in the snapshot (#56220)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56220 Changelog: [Internal] Conversion operators like `operator jsi::Array` contain a type reference in their name that was not being fully qualified. This diff adds a `_qualify_conversion_operator_type` step to `FunctionMember.close()` that detects conversion operators and qualifies the type portion of the name using the same mechanism already used for return types and arguments. Reviewed By: cipolleschi Differential Revision: D98124781 fbshipit-source-id: 7baf2b6f31fcbf2fdab43457b5792558d774b043
This commit is contained in:
1 parent
f516811a95
commit
7b3277f358
4 files changed
+52
-1
No files matched your search
@@ -65,6 +65,26 @@ class FunctionMember(Member):
|
||||
self.type = qualify_type_str(self.type, scope)
|
||||
self.arguments = qualify_arguments(self.arguments, scope)
|
||||
self._qualify_specialization_args(scope)
|
||||
self._qualify_conversion_operator_type(scope)
|
||||
|
||||
def _qualify_conversion_operator_type(self, scope: Scope) -> None:
|
||||
"""Qualify the type portion of conversion operator names.
|
||||
|
||||
Conversion operators like ``operator jsi::Array`` contain a type
|
||||
reference that may need namespace qualification (e.g., to
|
||||
``operator facebook::jsi::Array``).
|
||||
"""
|
||||
prefix = "operator "
|
||||
if not self.name.startswith(prefix):
|
||||
return
|
||||
|
||||
type_part = self.name[len(prefix) :]
|
||||
if not type_part or not (type_part[0].isalpha() or type_part[0] == "_"):
|
||||
return
|
||||
|
||||
qualified = qualify_type_str(type_part, scope)
|
||||
if qualified != type_part:
|
||||
self.name = prefix + qualified
|
||||
|
||||
def to_string(
|
||||
self,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class test::Clss {
|
||||
public operator Other() const;
|
||||
public operator test::Other() const;
|
||||
}
|
||||
|
||||
class test::Other {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
struct outer::inner::Type {
|
||||
}
|
||||
|
||||
|
||||
struct outer::sibling::Clss {
|
||||
public operator outer::inner::Type();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 outer {
|
||||
|
||||
namespace inner {
|
||||
struct Type {};
|
||||
} // namespace inner
|
||||
|
||||
namespace sibling {
|
||||
|
||||
struct Clss {
|
||||
operator inner::Type();
|
||||
};
|
||||
|
||||
} // namespace sibling
|
||||
|
||||
} // namespace outer
|
||||
Reference in new issue
Block a user