[cxx-interop] Import const-qualified indirect fields with private setters (#83219)

We already make imported computed properties' setters private in
VisitFieldDecl(), but not in VisitIndirectFieldDecl(), which handles
things like the members of an anonymous union in another struct.
This commit is contained in:
John Hui
2025-07-24 19:04:58 -07:00
committed by GitHub
parent a5e6b8556a
commit 9b95242ac4
2 changed files with 7 additions and 1 deletions

View File

@@ -3371,6 +3371,12 @@ namespace {
result->setInterfaceType(type);
result->setIsObjC(false);
result->setIsDynamic(false);
if (decl->getType().isConstQualified()) {
// Note that in C++ there are ways to change the values of const
// members, so we don't use WriteImplKind::Immutable storage.
assert(result->supportsMutation());
result->overwriteSetterAccess(AccessLevel::Private);
}
Impl.recordImplicitUnwrapForDecl(result,
importedType.isImplicitlyUnwrapped());