Skip to content

Commit 59468f4

Browse files
authored
Merge pull request swiftlang#84537 from egorzhdan/egorzhdan/disable-deducing-this
[cxx-interop] Do not import C++23 deducing this
2 parents 6cb3181 + 75c7610 commit 59468f4

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

lib/ClangImporter/ImportName.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,10 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
15381538
if (!swift3OrLaterName && isa<clang::CXXMethodDecl>(D)) {
15391539
return ImportedName();
15401540
}
1541+
// If this function uses C++23 deducing this, bail.
1542+
if (auto functionDecl = dyn_cast<clang::FunctionDecl>(D))
1543+
if (functionDecl->hasCXXExplicitFunctionObjectParameter())
1544+
return {};
15411545

15421546
// Dig out the definition, if there is one.
15431547
if (auto def = getDefinitionForClangTypeDecl(D)) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct HasDeducingThis {
2+
int value;
3+
int deducingRef(this HasDeducingThis &self) { return self.value; }
4+
};

test/Interop/Cxx/class/method/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
module DeducingThis {
2+
header "deducing-this.h"
3+
requires cplusplus23
4+
}
5+
16
module Methods {
27
header "methods.h"
38
requires cplusplus
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=DeducingThis -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++23 | %FileCheck %s
2+
3+
// This mostly ensures that we don't import deducing this method with an incorrect signature.
4+
5+
// CHECK: struct HasDeducingThis {
6+
// CHECK-NOT: deducingRef

0 commit comments

Comments
 (0)