Skip to content

Commit ea91b02

Browse files
authored
Merge pull request #61221 from apple/egorzhdan/cxx-successor-no-immortal-pt2
[cxx-interop] Do not synthesize `successor()` for foreign reference types
2 parents aa6f99a + 16ce2f9 commit ea91b02

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,21 +2221,10 @@ namespace {
22212221
MD->overwriteAccess(AccessLevel::Private);
22222222
} else if (cxxOperatorKind ==
22232223
clang::OverloadedOperatorKind::OO_PlusPlus) {
2224-
// Make sure the type is not an immortal foreign reference type.
2224+
// Make sure the type is not a foreign reference type.
22252225
// We cannot handle `operator++` for those types, since the
22262226
// current implementation creates a new instance of the type.
2227-
bool isImmortal = false;
2228-
if (auto classDecl = dyn_cast<ClassDecl>(result)) {
2229-
auto retainOperation = evaluateOrDefault(
2230-
Impl.SwiftContext.evaluator,
2231-
CustomRefCountingOperation(
2232-
{classDecl, CustomRefCountingOperationKind::retain}),
2233-
{});
2234-
isImmortal = retainOperation.kind ==
2235-
CustomRefCountingOperationResult::immortal;
2236-
}
2237-
2238-
if (cxxMethod->param_empty() && !isImmortal) {
2227+
if (cxxMethod->param_empty() && !isa<ClassDecl>(result)) {
22392228
// This is a pre-increment operator. We synthesize a
22402229
// non-mutating function called `successor() -> Self`.
22412230
FuncDecl *successorFunc = synthesizer.makeSuccessorFunc(MD);

0 commit comments

Comments
 (0)