diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp index 57dac3fdbbcab..b74ef5085924a 100644 --- a/lib/ClangImporter/ImportName.cpp +++ b/lib/ClangImporter/ImportName.cpp @@ -1538,6 +1538,10 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D, if (!swift3OrLaterName && isa(D)) { return ImportedName(); } + // If this function uses C++23 deducing this, bail. + if (auto functionDecl = dyn_cast(D)) + if (functionDecl->hasCXXExplicitFunctionObjectParameter()) + return {}; // Dig out the definition, if there is one. if (auto def = getDefinitionForClangTypeDecl(D)) { diff --git a/test/Interop/Cxx/class/method/Inputs/deducing-this.h b/test/Interop/Cxx/class/method/Inputs/deducing-this.h new file mode 100644 index 0000000000000..35bdd29c7357d --- /dev/null +++ b/test/Interop/Cxx/class/method/Inputs/deducing-this.h @@ -0,0 +1,4 @@ +struct HasDeducingThis { + int value; + int deducingRef(this HasDeducingThis &self) { return self.value; } +}; diff --git a/test/Interop/Cxx/class/method/Inputs/module.modulemap b/test/Interop/Cxx/class/method/Inputs/module.modulemap index 9a27e5c97da9e..20e8fb1d94dc1 100644 --- a/test/Interop/Cxx/class/method/Inputs/module.modulemap +++ b/test/Interop/Cxx/class/method/Inputs/module.modulemap @@ -1,3 +1,8 @@ +module DeducingThis { + header "deducing-this.h" + requires cplusplus23 +} + module Methods { header "methods.h" requires cplusplus diff --git a/test/Interop/Cxx/class/method/deducing-this-module-interface.swift b/test/Interop/Cxx/class/method/deducing-this-module-interface.swift new file mode 100644 index 0000000000000..324333d8809a5 --- /dev/null +++ b/test/Interop/Cxx/class/method/deducing-this-module-interface.swift @@ -0,0 +1,6 @@ +// 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 + +// This mostly ensures that we don't import deducing this method with an incorrect signature. + +// CHECK: struct HasDeducingThis { +// CHECK-NOT: deducingRef